Skip to content
Permalink
Browse files

Fix jest snapshot testing on windows

Summary:
Fixes #19370

Applied changes to existing project that uses jest snapshot testing. Testing was broken before and now works.

To verify: Run any snapshot test containing an image reference on Windows before and after this PR.

[WINDOWS][BUGFIX][jest] - Fixed jest snapshot testing on windows
Closes #19496

Differential Revision: D8195947

Pulled By: hramos

fbshipit-source-id: 909b5fe7cfd8c6286baf161a227a359854a37603
  • Loading branch information...
sam-vdp authored and facebook-github-bot committed May 31, 2018
1 parent fecfa2a commit 216bce31632480ce70cc03b1b2a57ec12440afd7
Showing with 6 additions and 3 deletions.
  1. +1 −1 jest-preset.json
  2. +4 −1 jest/assetFileTransformer.js
  3. +1 −1 package.json
@@ -15,7 +15,7 @@
],
"transform": {
"^.+\\.js$": "babel-jest",
"^[./a-zA-Z0-9$_-]+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "<rootDir>/node_modules/react-native/jest/assetFileTransformer.js"
"^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "<rootDir>/node_modules/react-native/jest/assetFileTransformer.js"
},
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element)"
@@ -21,7 +21,10 @@ module.exports = {
// the Jest snapshot.
process: (_, filename) =>
`module.exports = {
testUri: ${JSON.stringify(path.relative(__dirname, filename))}
testUri:
${JSON.stringify(
path.relative(__dirname, filename).replace(/\\/g, '/'),
)}
};`,
getCacheKey: createCacheKeyFunction([__filename]),
};
@@ -20,7 +20,7 @@
},
"jest": {
"transform": {
"^[./a-zA-Z0-9$_-]+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "<rootDir>/jest/assetFileTransformer.js",
"^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "<rootDir>/jest/assetFileTransformer.js",
".*": "./jest/preprocessor.js"
},
"setupFiles": [

0 comments on commit 216bce3

Please sign in to comment.
You can’t perform that action at this time.