Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude files from running if they match with the ignoring pattern #5341

Merged
merged 1 commit into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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