Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit 26793ae

Browse files
fsonrandycoulman
authored andcommitted
Revert Jest moduleNameMapper regex back to a whitelist (react#1149)
Jest matches moduleNameMapper regexes with module names, not the full file path, so the negative lookahead doesn’t work for filtering out JS files, because they can be imported without the extension. So paths like `lodash.assign` and `../utils/range` were mislabeled as resources with unknown file extensions because they have a dot in the name. As a stopgap measure, revert the moduleNameMapper regex added in react#1077.
1 parent 7032521 commit 26793ae

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/react-scripts/utils/createJestConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
2424
moduleDirectories: [paths.appSrc, paths.appNodeModules, paths.ownNodeModules],
2525
moduleFileExtensions: ['jsx', 'js', 'json'],
2626
moduleNameMapper: {
27-
'^.+\\.(?!(js|jsx|css|scss|json)$)[^\\.]+$': resolve('config/jest/FileStub.js'),
27+
'^.+\\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve('config/jest/FileStub.js'),
2828
'^.+\\.(css|scss)$': resolve('config/jest/CSSStub.js')
2929
},
3030
setupFiles: [resolve('config/polyfills.js')],

0 commit comments

Comments
 (0)