Skip to content
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
Exclude files from running if they match with the ignoring pattern (w…
…hen run via file mode)
  • Loading branch information
Miguel Jimenez Esun committed Jan 18, 2018
commit 9c1a328516ce8cdc30314f5ac78a257149f1414f
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