Skip to content

Instantly share code, notes, and snippets.

@klyrr
Created March 5, 2018 15:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klyrr/c7393ccdabb35935ec2d1201d5eb4901 to your computer and use it in GitHub Desktop.
Save klyrr/c7393ccdabb35935ec2d1201d5eb4901 to your computer and use it in GitHub Desktop.
Filename `pathTransform.js`:
```
'use strict';
const path = require('path');
// This is a custom Jest transformer turning file imports into filenames.
// http://facebook.github.io/jest/docs/tutorial-webpack.html
module.exports = {
process(src, filename) {
return `module.exports = ${JSON.stringify(path.basename(filename))};`;
}
};
```
And in your `package.json` :
```
"jest": {
"transform": {
"^.+\\.svg$": "./pathTransform.js"
},
},
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment