5
5
* This source code is licensed under the MIT license found in the
6
6
* LICENSE file in the root directory of this source tree.
7
7
*/
8
- ' use strict' ;
8
+ " use strict" ;
9
9
10
- const fs = require ( 'fs' ) ;
11
- const chalk = require ( ' chalk' ) ;
12
- const paths = require ( ' ../../config/paths' ) ;
10
+ const fs = require ( "fs" ) ;
11
+ const chalk = require ( " chalk" ) ;
12
+ const paths = require ( " ../../config/paths" ) ;
13
13
14
14
module . exports = ( resolve , rootDir , isEjecting ) => {
15
15
// Use this instead of `paths.testsSetup` to avoid putting
16
16
// an absolute filename into configuration after ejecting.
17
17
const setupTestsFile = fs . existsSync ( paths . testsSetup )
18
- ? ' <rootDir>/src/setupTests.js'
18
+ ? " <rootDir>/src/setupTests.js"
19
19
: undefined ;
20
20
21
21
// TODO: I don't know if it's safe or not to just use / as path separator
22
22
// in Jest configs. We need help from somebody with Windows to determine this.
23
23
const config = {
24
- collectCoverageFrom : [ ' src/**/*.{js,jsx}' ] ,
25
- setupFiles : [ resolve ( ' config/polyfills.js' ) ] ,
24
+ collectCoverageFrom : [ " src/**/*.{js,jsx}" ] ,
25
+ setupFiles : [ resolve ( " config/polyfills.js" ) ] ,
26
26
setupTestFrameworkScriptFile : setupTestsFile ,
27
27
testMatch : [
28
- ' <rootDir>/src/**/__tests__/**/*.js?(x)' ,
29
- ' <rootDir>/src/**/?(*.)(spec|test).js?(x)' ,
28
+ " <rootDir>/src/**/__tests__/**/*.js?(x)" ,
29
+ " <rootDir>/src/**/?(*.)(spec|test).js?(x)"
30
30
] ,
31
- testEnvironment : ' node' ,
32
- testURL : ' http://localhost' ,
31
+ testEnvironment : " node" ,
32
+ testURL : " http://localhost" ,
33
33
transform : {
34
- ' ^.+\\.(js|jsx)$' : isEjecting
35
- ? ' <rootDir>/node_modules/babel-jest'
36
- : resolve ( ' config/jest/babelTransform.js' ) ,
37
- ' ^.+\\.css$' : resolve ( ' config/jest/cssTransform.js' ) ,
38
- ' ^(?!.*\\.(js|jsx|css|json)$)' : resolve ( ' config/jest/fileTransform.js' ) ,
34
+ " ^.+\\.(js|jsx)$" : isEjecting
35
+ ? " <rootDir>/node_modules/babel-jest"
36
+ : resolve ( " config/jest/babelTransform.js" ) ,
37
+ " ^.+\\.( css|s[ca]ss)$" : resolve ( " config/jest/cssTransform.js" ) ,
38
+ " ^(?!.*\\.(js|jsx|css|json)$)" : resolve ( " config/jest/fileTransform.js" )
39
39
} ,
40
- transformIgnorePatterns : [ ' [/\\\\]node_modules[/\\\\].+\\.(js|jsx)$' ] ,
40
+ transformIgnorePatterns : [ " [/\\\\]node_modules[/\\\\].+\\.(js|jsx)$" ] ,
41
41
moduleNameMapper : {
42
- ' ^react-native$' : ' react-native-web' ,
42
+ " ^react-native$" : " react-native-web"
43
43
} ,
44
- moduleFileExtensions : [ ' web.js' , 'js' , ' json' , ' web.jsx' , ' jsx' , ' node' ] ,
44
+ moduleFileExtensions : [ " web.js" , "js" , " json" , " web.jsx" , " jsx" , " node" ]
45
45
} ;
46
46
if ( rootDir ) {
47
47
config . rootDir = rootDir ;
48
48
}
49
49
const overrides = Object . assign ( { } , require ( paths . appPackageJson ) . jest ) ;
50
50
const supportedKeys = [
51
- ' collectCoverageFrom' ,
52
- ' coverageReporters' ,
53
- ' coverageThreshold' ,
54
- ' snapshotSerializers' ,
51
+ " collectCoverageFrom" ,
52
+ " coverageReporters" ,
53
+ " coverageThreshold" ,
54
+ " snapshotSerializers"
55
55
] ;
56
56
if ( overrides ) {
57
57
supportedKeys . forEach ( key => {
@@ -64,21 +64,21 @@ module.exports = (resolve, rootDir, isEjecting) => {
64
64
if ( unsupportedKeys . length ) {
65
65
console . error (
66
66
chalk . red (
67
- ' Out of the box, Create React App only supports overriding ' +
68
- ' these Jest options:\n\n' +
69
- supportedKeys . map ( key => chalk . bold ( ' \u2022 ' + key ) ) . join ( '\n' ) +
70
- ' .\n\n' +
71
- ' These options in your package.json Jest configuration ' +
72
- ' are not currently supported by Create React App:\n\n' +
67
+ " Out of the box, Create React App only supports overriding " +
68
+ " these Jest options:\n\n" +
69
+ supportedKeys . map ( key => chalk . bold ( " \u2022 " + key ) ) . join ( "\n" ) +
70
+ " .\n\n" +
71
+ " These options in your package.json Jest configuration " +
72
+ " are not currently supported by Create React App:\n\n" +
73
73
unsupportedKeys
74
- . map ( key => chalk . bold ( ' \u2022 ' + key ) )
75
- . join ( '\n' ) +
76
- ' \n\nIf you wish to override other Jest options, you need to ' +
77
- ' eject from the default setup. You can do so by running ' +
78
- chalk . bold ( ' npm run eject' ) +
79
- ' but remember that this is a one-way operation. ' +
80
- ' You may also file an issue with Create React App to discuss ' +
81
- ' supporting more options out of the box.\n'
74
+ . map ( key => chalk . bold ( " \u2022 " + key ) )
75
+ . join ( "\n" ) +
76
+ " \n\nIf you wish to override other Jest options, you need to " +
77
+ " eject from the default setup. You can do so by running " +
78
+ chalk . bold ( " npm run eject" ) +
79
+ " but remember that this is a one-way operation. " +
80
+ " You may also file an issue with Create React App to discuss " +
81
+ " supporting more options out of the box.\n"
82
82
)
83
83
) ;
84
84
process . exit ( 1 ) ;
0 commit comments