diff --git a/jest-preset.json b/jest-preset.json index afd12eb96e7326..c7fb437e470b41 100644 --- a/jest-preset.json +++ b/jest-preset.json @@ -15,7 +15,7 @@ ], "transform": { "^.+\\.js$": "babel-jest", - "^[./a-zA-Z0-9$_-]+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "/node_modules/react-native/jest/assetFileTransformer.js" + "^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "/node_modules/react-native/jest/assetFileTransformer.js" }, "transformIgnorePatterns": [ "node_modules/(?!(jest-)?react-native|react-clone-referenced-element)" diff --git a/jest/assetFileTransformer.js b/jest/assetFileTransformer.js index da6cf34a0da57c..85f4a7bceb2a7f 100644 --- a/jest/assetFileTransformer.js +++ b/jest/assetFileTransformer.js @@ -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]), }; diff --git a/package.json b/package.json index d619cb176d4087..373cdc2e6b8c57 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ }, "jest": { "transform": { - "^[./a-zA-Z0-9$_-]+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "/jest/assetFileTransformer.js", + "^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "/jest/assetFileTransformer.js", ".*": "./jest/preprocessor.js" }, "setupFiles": [