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

Use testPathPattern as a filter on top of findRelatedTests #8311

Closed
wants to merge 22 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
92837e0
use testPathPattern as a filter on top of findRelatedTests
Apr 11, 2019
808564a
null check testPathPattern and eventually get around to fixing failin…
Apr 11, 2019
f7eafee
use _filterTestPathsWithStats to to filter by with testPathPattern
Apr 12, 2019
5eddcbd
remove unnecessary code
Apr 12, 2019
d83b4c6
update _filterTestPathsWithStats condition
Apr 12, 2019
7ee3e54
convert findRelatedTests parameter from a boolean to a string array
Apr 17, 2019
9d7aed1
fix linting issues
Apr 17, 2019
813fab3
fix instances of findRelatedTests
mackness Apr 24, 2019
b9ad8bc
explicitly check for more than 0 related tests
mackness May 4, 2019
2613dd0
explicit find related tests length check
mackness May 4, 2019
17b4310
fix failing normalize spec
mackness May 4, 2019
f95a0d4
normalize and null check find related tests
mackness Jun 2, 2019
bfa2569
Merge branch 'master' into find-related-tests-bug
mackness Jun 2, 2019
a85dd4b
lockfile
mackness Jun 2, 2019
4e99139
udpate show config and log debug messages snapshots
mackness Jun 2, 2019
4169622
update find related files snapshots
mackness Jun 2, 2019
9c001f7
udpate summary message in find related tests spec
mackness Jun 2, 2019
144e6f0
add a simple --testPathPattern assertion
mackness Jun 3, 2019
e73ecd7
disable prefer-const rule
mackness Jun 3, 2019
c33284d
disable no-unresolved rule for fsevents
mackness Jun 3, 2019
a938c25
Merge branch 'master' into find-related-tests-bug
mackness Jun 8, 2019
7dc3269
remove unused @ts-ignore comments
mackness Jun 8, 2019
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
11 changes: 10 additions & 1 deletion packages/jest-core/src/SearchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,19 @@ export default class SearchSource {
} else if (globalConfig.runTestsByPath && paths && paths.length) {
return this.findTestsByPaths(paths);
} else if (globalConfig.findRelatedTests && paths && paths.length) {
return this.findRelatedTestsFromPattern(
const relatedTests = this.findRelatedTestsFromPattern(
paths,
globalConfig.collectCoverage,
);
if (globalConfig.testPathPattern !== null) {
return {
tests: relatedTests.tests.filter(test =>
new RegExp(globalConfig.testPathPattern).test(test.path),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably try to reuse the logic in _filterTestPathsWithStats on the related tests, hopefully this helps as a hint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is very helpful, I was wondering why was not seeing the stats output when 0 tests were matched. Making the update now!

),
};
} else {
return relatedTests;
}
} else if (globalConfig.testPathPattern != null) {
return this.findMatchingTests(globalConfig.testPathPattern);
} else {
Expand Down