@@ -13,20 +13,18 @@ const pathExists = require('path-exists');
13
13
const paths = require ( '../config/paths' ) ;
14
14
15
15
module . exports = ( resolve , rootDir , isEjecting ) => {
16
- const setupFiles = [ resolve ( 'config/polyfills.js' ) ] ;
17
- if ( pathExists . sync ( paths . testsSetup ) ) {
18
- // Use this instead of `paths.testsSetup` to avoid putting
19
- // an absolute filename into configuration after ejecting.
20
- setupFiles . push ( '<rootDir>/src/setupTests.js' ) ;
21
- }
16
+ // Use this instead of `paths.testsSetup` to avoid putting
17
+ // an absolute filename into configuration after ejecting.
18
+ const setupTestsFile = pathExists . sync ( paths . testsSetup ) ? '<rootDir>/src/setupTests.js' : undefined ;
22
19
23
20
const config = {
24
21
moduleFileExtensions : [ 'jsx' , 'js' , 'json' ] ,
25
22
moduleNameMapper : {
26
23
'^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$' : resolve ( 'config/jest/FileStub.js' ) ,
27
24
'^.+\\.css$' : resolve ( 'config/jest/CSSStub.js' )
28
25
} ,
29
- setupFiles : setupFiles ,
26
+ setupFiles : [ resolve ( 'config/polyfills.js' ) ] ,
27
+ setupTestFrameworkScriptFile : setupTestsFile ,
30
28
testPathIgnorePatterns : [ '<rootDir>/(build|docs|node_modules)/' ] ,
31
29
testEnvironment : 'node' ,
32
30
testRegex : '(/__tests__/.*|\\.(test|spec))\\.(js|jsx)$' ,
0 commit comments