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

Fix testPathPatterns when config is in subdirectory #14934

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

brandonchinn178
Copy link
Contributor

Summary

Resolves #14726. No CHANGELOG entry, as it fixes an issue with a new feature that's already in the CHANGELOG.

Follow up to #12519 (which fixes both #10746 and #8226). In this PR, we separate the TestPathPatterns class into two classes: one that just represents the list of patterns and one that can match the patterns against a test file. The separation is necessary because there are some uses where we aren't in a project, and can't match against a regex, but we do want to do static analysis of the patterns. For example, when outputting the test summary, we want to show the patterns the user specified, but the summary is global, not per-project.

I also made a change I had wanted to do in the initial PR, which is store TestPathPatterns directly in GlobalConfig. Now, the fact that patterns are represented as Array<string> is an implementation detail, and everything using the patterns can only use the provided API.

This will make even more sense when rootDir is removed from GlobalConfig, as discussed. It would be even nicer if ProjectConfig stored TestPathPatternsExecutor, but it was getting weird with InitialProjectConfig, so I didn't want to touch that.

Test plan

I wrote a new test that is executed with yarn jest testPathPatterns. It fails on main with "no tests found", and passes on this branch.

Copy link

netlify bot commented Mar 3, 2024

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f8c5a96
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/65e95abaf7a6820008fce5df
😎 Deploy Preview https://deploy-preview-14934--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brandonchinn178 brandonchinn178 force-pushed the bchinn-testpathpatterns-subprojects branch from cadc8f9 to 1ef878f Compare March 3, 2024 19:00
@brandonchinn178 brandonchinn178 force-pushed the bchinn-testpathpatterns-subprojects branch from 1ef878f to 827b3e2 Compare March 3, 2024 20:13
@brandonchinn178 brandonchinn178 force-pushed the bchinn-testpathpatterns-subprojects branch 2 times, most recently from ca5fc7e to 7da18ae Compare March 7, 2024 04:10
@brandonchinn178 brandonchinn178 force-pushed the bchinn-testpathpatterns-subprojects branch from 7da18ae to f8c5a96 Compare March 7, 2024 06:12
@brandonchinn178
Copy link
Contributor Author

@SimenB Okay CI should be good now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: v30 alpha: testPathPatterns that worked in the past not working any more.
1 participant