From b3ba64e5ace2d329dbff1c6da387c241db3da7d3 Mon Sep 17 00:00:00 2001 From: Ian Schmitz Date: Thu, 22 Nov 2018 21:14:25 -0800 Subject: [PATCH] Support setupTests.ts (#5698) --- config/webpack.config.js | 4 ++-- scripts/utils/createJestConfig.js | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/config/webpack.config.js b/config/webpack.config.js index 80391927084..746884a03eb 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -635,8 +635,8 @@ module.exports = function(webpackEnv) { '!**/*.json', '!**/__tests__/**', '!**/?(*.)(spec|test).*', - '!src/setupProxy.js', - '!src/setupTests.*', + '!**/src/setupProxy.*', + '!**/src/setupTests.*', ], watch: paths.appSrc, silent: true, diff --git a/scripts/utils/createJestConfig.js b/scripts/utils/createJestConfig.js index abfd92c8d3c..58c2ad48812 100644 --- a/scripts/utils/createJestConfig.js +++ b/scripts/utils/createJestConfig.js @@ -14,15 +14,13 @@ const paths = require('../../config/paths'); module.exports = (resolve, rootDir, isEjecting) => { // Use this instead of `paths.testsSetup` to avoid putting // an absolute filename into configuration after ejecting. - const setupTestsMatches = paths.testsSetup.match(/src\/setupTests\.(.+)/); + const setupTestsMatches = paths.testsSetup.match(/src[/\\]setupTests\.(.+)/); const setupTestsFileExtension = (setupTestsMatches && setupTestsMatches[1]) || 'js'; const setupTestsFile = fs.existsSync(paths.testsSetup) ? `/src/setupTests.${setupTestsFileExtension}` : undefined; - // TODO: I don't know if it's safe or not to just use / as path separator - // in Jest configs. We need help from somebody with Windows to determine this. const config = { collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'],