-
-
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
Fix absolute path check for Windows #15235
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Right, this seems reasonable. Can we add a test as well? |
wouldn't the following block, where it checks for a relative path, suffer the same problem for windows relative paths? |
@connectdotz You mean because it would be |
Yes. I saw your change, and it should work for most cases. However, I did notice at least one use case where it might not work: a relative path pattern with a leading escape, such as It seems the complexity here is due to the fact that we are dealing with a regex pattern for the path, not the path itself. In any case, our extension doesn't use relative path patterns, so this may not be relevant for us. However, I wanted to bring this potential issue to your attention so you can decide how (or if) you'd like to handle it. |
I don't think that's an expected usage. We use a regex to match, yes, but the user input isnt a regex; in isMatch, we escape the entire path to make it a literal regex. I think I tried doing something originally like "strip root directory from the test filename, then check if filter is a substring in test filename" and not use regex at all, but I think it broke something else... |
Doesn't However, I do agree that to match a file like That said, we should probably model the implementation using the current jest |
@connectdotz You're right, it is supposed to be a regex. This is what I get for skimming PRs on my phone 😄 However, your example here:
I don't think this ever worked. I just tested this in a new project with jest 29. The reason that @SimenB You're right, I just took another look at the docs. I think the problem here is that this option tries to be both a path and a regex. This has some odd behavior: $ cd /home/jdoe/my-project/
$ tree .
.
|-- foo.spec.js
|-- dir1/
|-- dir2/
|-- bar.spec.js
$ jest './foo.spec.js'
Path: /home/jdoe/my-project/foo.spec.js => MATCH (t/foo.spec.js)
Path: /home/jdoe/my-project/dir1/dir2/bar.spec.js => NO MATCH
$ jest '\./foo.spec.js'
Path: /home/jdoe/my-project/foo.spec.js => NO MATCH
Path: /home/jdoe/my-project/dir1/dir2/bar.spec.js => NO MATCH
$ jest '../foo.spec.js'
Path: /home/jdoe/my-project/foo.spec.js => MATCH (ct/foo.spec.js)
Path: /home/jdoe/my-project/dir1/dir2/bar.spec.js => NO MATCH
$ jest 'dir1/../foo.spec.js'
Path: /home/jdoe/my-project/foo.spec.js => NO MATCH
Path: /home/jdoe/my-project/dir1/dir2/bar.spec.js => NO MATCH
$ jest './bar.spec.js'
Path: /home/jdoe/my-project/foo.spec.js => NO MATCH
Path: /home/jdoe/my-project/dir1/dir2/bar.spec.js => MATCH (2/bar.spec.js) @SimenB Can I propose we have the following semantics:
This most closely matches the spirit of the option, it seems like. The only breaking change here is that The alternative is to special case the leading
|
I would have preferred them being globs rather than regexes, but I guess it's way to late to change that now 😅
Seems fine - you're passing a relative path, it should probably only match relatively to where the command is used? |
Latest changes look promising! @connectdotz could you give them a quick test? |
Yes, it works with our use case. 👍 |
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.
thanks!
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
Fixes #15109, regression introduced in #12519
Test plan