Skip to content

Commit 49e258b

Browse files
authored
Support setupTests.ts (facebook#5698)
1 parent d9ee05c commit 49e258b

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/react-scripts/config/webpack.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,8 @@ module.exports = function(webpackEnv) {
635635
'!**/*.json',
636636
'!**/__tests__/**',
637637
'!**/?(*.)(spec|test).*',
638-
'!src/setupProxy.js',
639-
'!src/setupTests.*',
638+
'!**/src/setupProxy.*',
639+
'!**/src/setupTests.*',
640640
],
641641
watch: paths.appSrc,
642642
silent: true,

packages/react-scripts/scripts/utils/createJestConfig.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ const paths = require('../../config/paths');
1414
module.exports = (resolve, rootDir, isEjecting) => {
1515
// Use this instead of `paths.testsSetup` to avoid putting
1616
// an absolute filename into configuration after ejecting.
17-
const setupTestsMatches = paths.testsSetup.match(/src\/setupTests\.(.+)/);
17+
const setupTestsMatches = paths.testsSetup.match(/src[/\\]setupTests\.(.+)/);
1818
const setupTestsFileExtension =
1919
(setupTestsMatches && setupTestsMatches[1]) || 'js';
2020
const setupTestsFile = fs.existsSync(paths.testsSetup)
2121
? `<rootDir>/src/setupTests.${setupTestsFileExtension}`
2222
: undefined;
2323

24-
// TODO: I don't know if it's safe or not to just use / as path separator
25-
// in Jest configs. We need help from somebody with Windows to determine this.
2624
const config = {
2725
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'],
2826

0 commit comments

Comments
 (0)