Skip to content

Commit

Permalink
Revert Jest moduleNameMapper regex back to a whitelist (facebook#1149)
Browse files Browse the repository at this point in the history
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 facebook#1077.
  • Loading branch information
fson authored and randycoulman committed May 8, 2017
1 parent 7032521 commit 26793ae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
moduleDirectories: [paths.appSrc, paths.appNodeModules, paths.ownNodeModules],
moduleFileExtensions: ['jsx', 'js', 'json'],
moduleNameMapper: {
'^.+\\.(?!(js|jsx|css|scss|json)$)[^\\.]+$': resolve('config/jest/FileStub.js'),
'^.+\\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve('config/jest/FileStub.js'),
'^.+\\.(css|scss)$': resolve('config/jest/CSSStub.js')
},
setupFiles: [resolve('config/polyfills.js')],
Expand Down

0 comments on commit 26793ae

Please sign in to comment.