Skip to content

Commit

Permalink
Exclude files from running if they match with the ignoring pattern (w…
Browse files Browse the repository at this point in the history
…hen run via file mode) (#5341)
  • Loading branch information
mjesun committed Jan 18, 2018
1 parent 054271c commit a33ffa1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion integration-tests/__tests__/execute-tests-once-in-mpr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: ['<rootDir>/foo/*/'],
projects: ['<rootDir>', '<rootDir>/foo/*/'],
testPathIgnorePatterns: ['/foo/'],
testRegex: /my-test-.*\.js/.source,
},
};

Expand Down
15 changes: 11 additions & 4 deletions packages/jest-cli/src/search_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a33ffa1

Please sign in to comment.