Skip to content

Commit

Permalink
Add "node" to Jest's moduleFileExtensions (#2738)
Browse files Browse the repository at this point in the history
Jest's default value for this option is ["js", "json", "jsx", "node"].
CRA's current value is ["web.js", "js", "json", "web.jsx", "jsx"], which
is missing one of default ones: "node". This change fixes that.

This "node" extension is used in packages that use native code.
  • Loading branch information
mostafah authored and JohnNilsson committed Sep 9, 2017
1 parent 4b856a7 commit 31e3ffe
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions packages/react-scripts/scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@ module.exports = (resolve, rootDir) => {
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
setupFiles: [resolve('config/polyfills.js')],
setupTestFrameworkScriptFile: setupTestsFile,
moduleFileExtensions: [
'web.ts',
'ts',
'web.tsx',
'tsx',
'web.js',
'js',
'web.jsx',
'jsx',
'json',
],
testMatch: [
'<rootDir>/src/**/__tests__/**/*.ts?(x)',
'<rootDir>/src/**/?(*.)(spec|test).ts?(x)',
Expand All @@ -47,14 +36,26 @@ module.exports = (resolve, rootDir) => {
transform: {
'^.+\\.css$': resolve('config/jest/cssTransform.js'),
'^.+\\.tsx?$': resolve('config/jest/typescriptTransform.js'),
'^(?!.*\\.(css|json)$)': resolve('config/jest/fileTransform.js'),
'^(?!.*\\.(js|jsx|css|json)$)': resolve('config/jest/fileTransform.js'),
},
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$',
],
moduleNameMapper: {
'^react-native$': 'react-native-web',
},
moduleFileExtensions: [
'web.ts',
'ts',
'web.tsx',
'tsx',
'web.js',
'js',
'web.jsx',
'jsx',
'json',
'node'
],
globals: {
'ts-jest': {
tsConfigFile: paths.appTsTestConfig,
Expand Down

0 comments on commit 31e3ffe

Please sign in to comment.