Created
March 5, 2018 15:13
-
-
Save klyrr/c7393ccdabb35935ec2d1201d5eb4901 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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