-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Conversation
@mackness Thanks for taking time to tackle this, let us know if you get stuck anywhere :) |
if (globalConfig.testPathPattern !== null) { | ||
return { | ||
tests: relatedTests.tests.filter(test => | ||
new RegExp(globalConfig.testPathPattern).test(test.path), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
We only want to _filterTestPathsWithStats if testPathPattern was explicitly passed as an argument. The issue is that it's not possible to simply null check globalConfig.testPathPattern to determine if it was explicity passed becase that field gets populated with values passed to findRelatedTests also. This approach compares the values in globalConfig.testPathPattern to the values in globalConfig.nonFlagArgs and if it is a 1 to 1 match it is assumed that testPathPattern was not explicity passed as an argument.
Codecov Report
@@ Coverage Diff @@
## master #8311 +/- ##
==========================================
- Coverage 62.17% 62.15% -0.03%
==========================================
Files 266 266
Lines 10683 10687 +4
Branches 2597 2598 +1
==========================================
Hits 6642 6642
- Misses 3452 3456 +4
Partials 589 589
Continue to review full report at Codecov.
|
@mackness I just took a look at your updates - it appears that the root cause of what you worked around with d83b4c6 is that we are using all the non-option arguments to find related tests, so the non-option arguments become both parts of |
@jeysal That seems like a much better approach, my workaround definitely did not feel right. I'll let you know if I runt into any issues with the implementation, thanks for the suggestion! |
Hi @jeysal I am letting
I will keep trying to track down the root cause of 1 and 2 but a little bit of direction with 3 would be greatly appreciated, thanks! |
@mackness After a quick glance, most of the snapshots seem like legimitate failures that need fixing to me. There's also coverage related failures. Coverage has special interaction with stuff like |
@jeysal Ok awesome I'll work on making the tests pass and adding a couple tests of my own, thanks! |
findRelatedTests used to be a boolean field. It has been updated to be Array<string>. We will check the length of the array to determine if findRelatedTests is falsy or truthy since 0 will evaluate to false and aything greater than 0 will evaluate to true.
yep, I'll make the change :) |
simple test that asserts --testPathPattern will filter tests matched by --findRelatedTests
for some reason this lint command works locally but fails in CI eslint . --cache --report-unused-disable-directives --ext js,jsx,ts,tsx,md --format junit -o reports/junit/js-lint-results.xml
@mackness Let me know when you think this is ready for review again or if you run into any other problems :) |
@jeysal Thanks! I am planning on adding a few more unit tests and there are a couple typing issues I need to take care of then It will be ready for another review. One question this fails in CI but it does not fail locally. Also it does not seem related to code I changed. Do you know what might be causing eslint to complain about no-unresolved? Maybe because fsevents is an optional dependency in jest-haste-map? https://github.com/facebook/jest/blob/master/packages/jest-haste-map/package.json#L35 |
Yeah I get those too, idk why - maybe @SimenB knows? |
I think this is due to |
This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Based on this issue #5129
--findRelatedTests
is overriding--testPathPattern
. The goal of this PR is to apply--testPathPattern
as a filter on top of results returned by--findRelatedTests
.Test plan
Planning on adding tests for the
_getTestPaths
method inSearchSource.ts