diff --git a/utils/createJestConfig.js b/utils/createJestConfig.js index 41409ab..7eb9f97 100644 --- a/utils/createJestConfig.js +++ b/utils/createJestConfig.js @@ -13,12 +13,9 @@ const pathExists = require('path-exists'); const paths = require('../config/paths'); module.exports = (resolve, rootDir, isEjecting) => { - const setupFiles = [resolve('config/polyfills.js')]; - if (pathExists.sync(paths.testsSetup)) { - // Use this instead of `paths.testsSetup` to avoid putting - // an absolute filename into configuration after ejecting. - setupFiles.push('/src/setupTests.js'); - } + // Use this instead of `paths.testsSetup` to avoid putting + // an absolute filename into configuration after ejecting. + const setupTestsFile = pathExists.sync(paths.testsSetup) ? '/src/setupTests.js' : undefined; const config = { moduleFileExtensions: ['jsx', 'js', 'json'], @@ -26,7 +23,8 @@ module.exports = (resolve, rootDir, isEjecting) => { '^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve('config/jest/FileStub.js'), '^.+\\.css$': resolve('config/jest/CSSStub.js') }, - setupFiles: setupFiles, + setupFiles: [resolve('config/polyfills.js')], + setupTestFrameworkScriptFile: setupTestsFile, testPathIgnorePatterns: ['/(build|docs|node_modules)/'], testEnvironment: 'node', testRegex: '(/__tests__/.*|\\.(test|spec))\\.(js|jsx)$',