Skip to content

Commit 715de0d

Browse files
authored
Revert Jest moduleNameMapper regex back to a whitelist (#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 #1077.
1 parent b57d871 commit 715de0d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/react-scripts/utils/createJestConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
2020
const config = {
2121
collectCoverageFrom: ['src/**/*.{js,jsx}'],
2222
moduleNameMapper: {
23-
'^.+\\.(?!(js|jsx|css|json)$)[^\\.]+$': resolve('config/jest/FileStub.js'),
23+
'^.+\\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve('config/jest/FileStub.js'),
2424
'^.+\\.css$': resolve('config/jest/CSSStub.js')
2525
},
2626
setupFiles: [resolve('config/polyfills.js')],

0 commit comments

Comments
 (0)