Skip to content
This repository has been archived by the owner on Dec 3, 2018. It is now read-only.

Commit

Permalink
load setupTests file at setupTestFramework stage (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
just-boris authored and gaearon committed Oct 5, 2016
1 parent 2d1424f commit 61bc387
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ 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'],
moduleNameMapper: {
'^.+\\.(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)$',
Expand Down

0 comments on commit 61bc387

Please sign in to comment.