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
No related merge requests found
Showing with 5 additions and 7 deletions
+5 -7
...@@ -13,12 +13,9 @@ const pathExists = require('path-exists'); ...@@ -13,12 +13,9 @@ const pathExists = require('path-exists');
const paths = require('../config/paths'); const paths = require('../config/paths');
module.exports = (resolve, rootDir, isEjecting) => { module.exports = (resolve, rootDir, isEjecting) => {
const setupFiles = [resolve('config/polyfills.js')]; // Use this instead of `paths.testsSetup` to avoid putting
if (pathExists.sync(paths.testsSetup)) { // an absolute filename into configuration after ejecting.
// Use this instead of `paths.testsSetup` to avoid putting const setupTestsFile = pathExists.sync(paths.testsSetup) ? '<rootDir>/src/setupTests.js' : undefined;
// an absolute filename into configuration after ejecting.
setupFiles.push('<rootDir>/src/setupTests.js');
}
const config = { const config = {
moduleFileExtensions: ['jsx', 'js', 'json'], moduleFileExtensions: ['jsx', 'js', 'json'],
...@@ -26,7 +23,8 @@ module.exports = (resolve, rootDir, isEjecting) => { ...@@ -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'), '^.+\\.(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') '^.+\\.css$': resolve('config/jest/CSSStub.js')
}, },
setupFiles: setupFiles, setupFiles: [resolve('config/polyfills.js')],
setupTestFrameworkScriptFile: setupTestsFile,
testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'], testPathIgnorePatterns: ['<rootDir>/(build|docs|node_modules)/'],
testEnvironment: 'node', testEnvironment: 'node',
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(js|jsx)$', 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