Commit 15c20f17 authored by Boris Serdiuk's avatar Boris Serdiuk Committed by Dan Abramov
Browse files

load setupTests file at setupTestFramework stage (#846)

fixes facebookincubator/create-react-app#824
parent 11c9bdc6
Showing with 5 additions and 7 deletions
+5 -7
......@@ -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('<rootDir>/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) ? '<rootDir>/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: ['<rootDir>/(build|docs|node_modules)/'],
testEnvironment: 'node',
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(js|jsx)$',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment