@@ -13,20 +13,18 @@ const pathExists = require('path-exists');
1313const paths = require ( '../config/paths' ) ;
1414
1515module . 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 ;
2219
2320 const config = {
2421 moduleFileExtensions : [ 'jsx' , 'js' , 'json' ] ,
2522 moduleNameMapper : {
2623 '^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$' : resolve ( 'config/jest/FileStub.js' ) ,
2724 '^.+\\.css$' : resolve ( 'config/jest/CSSStub.js' )
2825 } ,
29- setupFiles : setupFiles ,
26+ setupFiles : [ resolve ( 'config/polyfills.js' ) ] ,
27+ setupTestFrameworkScriptFile : setupTestsFile ,
3028 testPathIgnorePatterns : [ '<rootDir>/(build|docs|node_modules)/' ] ,
3129 testEnvironment : 'node' ,
3230 testRegex : '(/__tests__/.*|\\.(test|spec))\\.(js|jsx)$' ,
0 commit comments