From f9277da183cd0114a4a327568deea42462097191 Mon Sep 17 00:00:00 2001 From: Mostafa Hajizadeh Date: Fri, 7 Jul 2017 15:07:32 +0430 Subject: [PATCH] Add "node" to Jest's moduleFileExtensions (#2738) 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. --- .../scripts/utils/createJestConfig.js | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 559f96f45..c5886ce0c 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -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: [ '/src/**/__tests__/**/*.ts?(x)', '/src/**/?(*.)(spec|test).ts?(x)', @@ -47,7 +36,7 @@ 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)$', @@ -55,6 +44,18 @@ module.exports = (resolve, rootDir) => { 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,