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
base: main
Are you sure you want to change the base?
Fix testPathPatterns when config is in subdirectory #14934
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
cadc8f9
to
1ef878f
Compare
1ef878f
to
827b3e2
Compare
ca5fc7e
to
7da18ae
Compare
7da18ae
to
f8c5a96
Compare
@SimenB Okay CI should be good now! |
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.
so sorry about the slow reply!
The code overall looks good to me, I'd just like to see it not be in @jest/types
. I can probably move it myself if you're busy 🙂
import {escapePathForRegex, replacePathSepForRegex} from 'jest-regex-util'; | ||
|
||
type PatternsConfig = { | ||
export class TestPathPatterns { |
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.
didn't notice this was here before 😅
I don't wanna export non-types from this package. I'm fine with not having it in jest-util
, but could you pull it out into its own new package?
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.
So it can't be in jest-util
because jest-util
imports from @jest/types
and TestPathPatterns
is used in GlobalConfig
, so there'd be a circular dependency.
But I broke it out into a new jest-pattern
library and pushed a commit. Hopefully it builds fine
7e4bc17
to
7e10a48
Compare
7e10a48
to
0d9ccdb
Compare
I'm not too sure about this change. Currently the config is JSON serializable - that changes if we stick a class instance on it 🤔 |
It should still be JSON serializable, because it implements toJSON Pretty sure theres a test somewhere checking this |
CI fails now with type errors in the tests. Not sure if that's something we wanna fix, or add the module to the ignore list: Lines 32 to 33 in 343d450
|
hm I'll take a look |
1c49224
to
c22a670
Compare
@SimenB seems like its passing now! |
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 inGlobalConfig
. Now, the fact that patterns are represented asArray<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 fromGlobalConfig
, as discussed. It would be even nicer ifProjectConfig
storedTestPathPatternsExecutor
, but it was getting weird withInitialProjectConfig
, 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.