Skip to content

Commit cdd736d

Browse files
authored
Fix mocking assets with special characters in the file path (#584)
The regexes in the Jest `moduleNameMapper` configs were a bit too strict, causing them to not pick up files with special characters like `@` in the file path. Change them to match anything with the correct file extension.
1 parent d3530f4 commit cdd736d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/utils/createJestConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module.exports = (resolve, rootDir) => {
2121
const config = {
2222
moduleFileExtensions: ['jsx', 'js', 'json'],
2323
moduleNameMapper: {
24-
'^[./a-zA-Z0-9$_-]+\\.(jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm)$': resolve('config/jest/FileStub.js'),
25-
'^[./a-zA-Z0-9$_-]+\\.css$': resolve('config/jest/CSSStub.js')
24+
'^.+\\.(jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm)$': resolve('config/jest/FileStub.js'),
25+
'^.+\\.css$': resolve('config/jest/CSSStub.js')
2626
},
2727
scriptPreprocessor: resolve('config/jest/transform.js'),
2828
setupFiles: setupFiles,

0 commit comments

Comments
 (0)