mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-28 17:35:42 +08:00
Add .mjs support (#3239)
This commit is contained in:
@@ -21,27 +21,37 @@ module.exports = (resolve, rootDir, isEjecting) => {
|
||||
// TODO: I don't know if it's safe or not to just use / as path separator
|
||||
// in Jest configs. We need help from somebody with Windows to determine this.
|
||||
const config = {
|
||||
collectCoverageFrom: ['src/**/*.{js,jsx}'],
|
||||
collectCoverageFrom: ['src/**/*.{js,jsx,mjs}'],
|
||||
setupFiles: [resolve('config/polyfills.js')],
|
||||
setupTestFrameworkScriptFile: setupTestsFile,
|
||||
testMatch: [
|
||||
'<rootDir>/src/**/__tests__/**/*.js?(x)',
|
||||
'<rootDir>/src/**/?(*.)(spec|test).js?(x)',
|
||||
'<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}',
|
||||
'<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}',
|
||||
],
|
||||
testEnvironment: 'node',
|
||||
testURL: 'http://localhost',
|
||||
transform: {
|
||||
'^.+\\.(js|jsx)$': isEjecting
|
||||
'^.+\\.(js|jsx|mjs)$': isEjecting
|
||||
? '<rootDir>/node_modules/babel-jest'
|
||||
: resolve('config/jest/babelTransform.js'),
|
||||
'^.+\\.css$': resolve('config/jest/cssTransform.js'),
|
||||
'^(?!.*\\.(js|jsx|css|json)$)': resolve('config/jest/fileTransform.js'),
|
||||
'^(?!.*\\.(js|jsx|mjs|css|json)$)': resolve(
|
||||
'config/jest/fileTransform.js'
|
||||
),
|
||||
},
|
||||
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
|
||||
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$'],
|
||||
moduleNameMapper: {
|
||||
'^react-native$': 'react-native-web',
|
||||
},
|
||||
moduleFileExtensions: ['web.js', 'js', 'json', 'web.jsx', 'jsx', 'node'],
|
||||
moduleFileExtensions: [
|
||||
'web.js',
|
||||
'mjs',
|
||||
'js',
|
||||
'json',
|
||||
'web.jsx',
|
||||
'jsx',
|
||||
'node',
|
||||
],
|
||||
};
|
||||
if (rootDir) {
|
||||
config.rootDir = rootDir;
|
||||
|
||||
Reference in New Issue
Block a user