GitXplorerGitXplorer
E

jest-transformer-svg

public
10 stars
6 forks
0 issues

Commits

List of commits on branch main.
Unverified
b273e1dcfc18ea4ef659d60a2ace71fc0cc1209c

feat: support react 19, switch to pnpm and testing library, resolve vulnerabilities

EEm-Ant committed 3 days ago
Unverified
26371281d6dec33a9d38487e9eb63aa61f520430

chore: update dependencies

committed a year ago
Unverified
58ba094392fe8371cfef5db6116c292fa9eeb48e

feat: extend jest peer dep to >= 28

EEm-Ant committed 2 years ago
Unverified
90a2089e799fa6d03ef96910eeda1f321e17316e

feat!: support jest 28 and react 18

EEm-Ant committed 3 years ago
Unverified
3ef0ef6dc0e5e74c529c60f7fe0b09c658424202

release 1.0.2

EEm-Ant committed 3 years ago
Verified
d276e1316a820372784e945e89869fd6cf3389af

Merge pull request #1 from GeuntaBuwono/chore/remove-unnecesary-script

EEm-Ant committed 3 years ago

README

The README file for this repository.

jest-transformer-svg

Transform svg files for for jest+react to de-clutter snapshots.

NOTE: cloned from jest-svg-transformer since it looks unmaintained, and it doesn't support Jest versions >= 27.

the latest version supports jest 28 - please use v1 for jest 27

Very useful with react-svg-loader. This allows you to import svgs directly into your react components, but still have nice snapshots.

Using enzyme's shallow rendering, for example:

import React from 'react';
import MySvg from '../images/an-image.svg';

function MyComponent() {
  return (
    <div>
      <MySvg style={{ color: 'blue' }} />
    </div>
  );
}

will result in a snapshot that looks like this:

<div>
    <SvgAnImage style={{color: 'blue'}} />
</div>

usage

This works with both enzyme and react-test-renderer.

Configure jest:

{
  "jest": {
    "transform": {
      "^.+\\.jsx?$": "babel-jest",
      "^.+\\.svg$": "jest-transformer-svg"
    }
  }
}