GitXplorerGitXplorer
E

jest-transformer-svg

public
10 stars
6 forks
0 issues

Commits

List of commits on branch main.
Unverified
2251a1f93ab35dc97d632b9dd906383ff9ad2828

chore: remove prepare script

GGeuntaBuwono committed 3 years ago
Unverified
54afdd033d603bb02dd68af41126e0f2c8541a94

test: do not use jest cache

EEm-Ant committed 4 years ago
Unverified
f1637f44614de5f507c0639154886ea1d0e58579

test: add testing

EEm-Ant committed 4 years ago
Unverified
d44047df0744667c7938706d2b2f26b7e4950160

fix: correct main path in package.json

EEm-Ant committed 4 years ago
Unverified
50612bc7ac93215c0f8eabfe88954ce34bf1238b

chore: improve package.json infos

EEm-Ant committed 4 years ago
Unverified
eeacf3f434da15e94be3ee6d965800b467455ff4

feat: first commit

EEm-Ant committed 4 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"
    }
  }
}