diff --git a/CHANGELOG.md b/CHANGELOG.md index 8088ce9eb0e2..cb2c40262a72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ ## master -* `[jest-editor-support]` Add option to spawn command in shell ([#5340](https://github.com/facebook/jest/pull/5340)) +## jest 22.1.3 + +### Fixes + +* `[jest-cli]` Check if the file belongs to the checked project before adding it + to the list, also checking that the file name is not explicitly blacklisted + ([#5341](https://github.com/facebook/jest/pull/5341)) +* `[jest-editor-support]` Add option to spawn command in shell + ([#5340](https://github.com/facebook/jest/pull/5340)) ## jest 22.1.2 diff --git a/integration-tests/__tests__/execute-tests-once-in-mpr.js b/integration-tests/__tests__/execute-tests-once-in-mpr.js index dd66aeb412ac..ec93e4523857 100644 --- a/integration-tests/__tests__/execute-tests-once-in-mpr.js +++ b/integration-tests/__tests__/execute-tests-once-in-mpr.js @@ -25,8 +25,9 @@ test('Tests are executed only once even in an MPR', () => { // Make a global config that ignores all sub-projects. const config = { jest: { - projects: ['/foo/*/'], + projects: ['', '/foo/*/'], testPathIgnorePatterns: ['/foo/'], + testRegex: /my-test-.*\.js/.source, }, }; diff --git a/packages/jest-cli/src/search_source.js b/packages/jest-cli/src/search_source.js index f56eebc5c583..d20bb18ef264 100644 --- a/packages/jest-cli/src/search_source.js +++ b/packages/jest-cli/src/search_source.js @@ -213,18 +213,25 @@ export default class SearchSource { const validTestPaths = paths && paths.filter(name => { + const fullName = path.resolve(name); + try { - if (!fs.lstatSync(name).isFile()) { - // It exists, but it is not a file; return false. + if (!fs.lstatSync(fullName).isFile()) { + // It exists, but it is not a file. return false; } } catch (e) { - // It does not exist; return false. + // It does not exist. + return false; + } + + // The file exists, but it is explicitly blacklisted. + if (!this._testPathCases.testPathIgnorePatterns(fullName)) { return false; } // It exists and it is a file; return true if it's in the project. - return allFiles.has(path.resolve(name)); + return allFiles.has(fullName); }); if (validTestPaths && validTestPaths.length) {