Skip to content

Commit a33ffa1

Browse files
authored
Exclude files from running if they match with the ignoring pattern (when run via file mode) (#5341)
1 parent 054271c commit a33ffa1

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
## master
22

3-
* `[jest-editor-support]` Add option to spawn command in shell ([#5340](https://github.com/facebook/jest/pull/5340))
3+
## jest 22.1.3
4+
5+
### Fixes
6+
7+
* `[jest-cli]` Check if the file belongs to the checked project before adding it
8+
to the list, also checking that the file name is not explicitly blacklisted
9+
([#5341](https://github.com/facebook/jest/pull/5341))
10+
* `[jest-editor-support]` Add option to spawn command in shell
11+
([#5340](https://github.com/facebook/jest/pull/5340))
412

513
## jest 22.1.2
614

integration-tests/__tests__/execute-tests-once-in-mpr.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ test('Tests are executed only once even in an MPR', () => {
2525
// Make a global config that ignores all sub-projects.
2626
const config = {
2727
jest: {
28-
projects: ['<rootDir>/foo/*/'],
28+
projects: ['<rootDir>', '<rootDir>/foo/*/'],
2929
testPathIgnorePatterns: ['/foo/'],
30+
testRegex: /my-test-.*\.js/.source,
3031
},
3132
};
3233

packages/jest-cli/src/search_source.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,25 @@ export default class SearchSource {
213213
const validTestPaths =
214214
paths &&
215215
paths.filter(name => {
216+
const fullName = path.resolve(name);
217+
216218
try {
217-
if (!fs.lstatSync(name).isFile()) {
218-
// It exists, but it is not a file; return false.
219+
if (!fs.lstatSync(fullName).isFile()) {
220+
// It exists, but it is not a file.
219221
return false;
220222
}
221223
} catch (e) {
222-
// It does not exist; return false.
224+
// It does not exist.
225+
return false;
226+
}
227+
228+
// The file exists, but it is explicitly blacklisted.
229+
if (!this._testPathCases.testPathIgnorePatterns(fullName)) {
223230
return false;
224231
}
225232

226233
// It exists and it is a file; return true if it's in the project.
227-
return allFiles.has(path.resolve(name));
234+
return allFiles.has(fullName);
228235
});
229236

230237
if (validTestPaths && validTestPaths.length) {

0 commit comments

Comments
 (0)