-
-
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
testMatch on Windows #7914
Comments
We moved to micromatch@3 and it seems like your glib is not valid anymore. You'll need to adjust it to be compliant. We're sorry this happens but it was announced as a breaking change |
I wonder if this is #7814? Seeing as OP says it works on unix |
@thymikee I know about the breaking change and we changed the glob, mainly I just use the default one shown in |
Oh, that may be the case. Reopening then |
@SimenB I am using v24.1 but if I add the |
@SimenB @thymikee When I create a config using
Then I just uncommented this block and tweaked a bit to support Now what I did is slightly change the glob and works in both OS, following the doc in micromatch.
Here the more important changes:
Could be that "just" the default for |
@artola That solves my issues after upgrading multiple of my projects to latest Jest. Befeorehand I had to add a bunch of ignore entries to stop it from picking up files that Jest thought had tests but didn't actually, resulting in fake fails. One such example is the Create React App's test.js script which actually executes Jest. |
Can we count on fix? |
Not sure what a fix would be? Is it a documentation or implementation issue? A PR for either is very much welcome as none on the core team uses windows. We do test windows on CI though, so if it's a code issue we can add a test as well |
@SimenB It is a code issue, see my comment above, a solution is wrap this return with It will be great if some Windows expert verifies and creates the PR. In the meantime the solution was change the micromatch as explained. |
Aight, fair enough! Looking forward to that PR 😊 |
yup, the focus is the path In windows default |
* Updating jest `testMatch` micromatch expressions (jestjs/jest#7914) * Replacing `/` with `path.sep` in icon-build-helpers search.js * Replacing regex using `/` with `[\\/]` in test-utils scss.js
Hello! I encountered a similar issue. The following wildcard works on Unix machines but does not work on Windows machines:
@SimenB, after some debugging I found that there is Here is this function:
I changed it to log the result and path:
So, the issue happens because this function converts glob patents on Windows machines in the following way:
The issue is in this place (in replaced part) It looks like ecranisation logic conflicts with double backslashes. So, if Additional notes:
Am I missing something? Or there is an issue? In my case, I found only one workaround for
change to
|
@SimenB correct me if I'm wrong, the test uses I want to take a stab at fixing this, but writing a separate test suite for Windows seems like a lot of work to me. |
edit: sigh I'm guessing I had some other botched config leading up to the issue I reported, as I've started over and am no longer experiencing the behavior I reported. |
This issue persists. I was able to reproduce this issue on Jest version 28.1.3 installed on Windows Version 10.0.22621. My The message I get when I run Jest is,
The path separators for |
+1 still experiencing issue in feb, 2023 |
One possible workaround when trying to get a launch.json file to work on Windows is to use this VSCode extension: I installed this, and then used the following launch.json configuration:
|
* Add v2 API return type interface * Add transform request function * Add test for level v8 * Fix type and normalizing logic * Windows test match fix jestjs/jest#7914
Thanks, your workaround worked for me on Windows 11 ❤️ ! |
Related to #3384 ## Initial fix Use the same @ pattern for @(test|src) as it was implemented for `@(spec|test)` in #1949 . It seems the current pattern used to work with Jest and micromatch on Windows but it must have been changed later and stopped working. This comment in Jest repo explains something similar jestjs/jest#7914 (comment) > +(spec|test) => @(spec|test) ... from 1 or more occurrences to matches 1 ## Second possible fix On the other hand, I couldn't find any `*.spec.ts` or `*.test.ts` inside the `src` folder , but only in `tests` folder. We could simplify the Jest pattern match from ```json "<rootDir>/@(test|src)/**/*(*.)@(spec|test).ts?(x)" ``` to ```json "<rootDir>/test/**/*(*.)@(spec|test).ts?(x)" ``` I tested this last pattern and it also worked fine. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
The following
testMatch
works on unix systems while does not on Windows machines. It is required to narrow the folders where to look for tests.Error on Windows:
To Reproduce
Set a
testMatch
that starts with<rootDir>/src/...
in place of the default**/*/...
.See in the error message
src/**\?(*.)
here the/
was replaced by\
and it is a lonely case.Expected behavior
testMatch
should work cross OS as in v23.Link to repl or repo (highly encouraged)
this repro work in v22 while fails in v24 with Windows: https://repl.it/@artola/jest-bug
Run
npx envinfo --preset jest
Paste the results here:
System: OS: macOS 10.14.3 CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz Binaries: Node: 11.9.0 - /usr/local/bin/node Yarn: 1.13.0 - /usr/local/bin/yarn npm: 6.5.0 - /usr/local/bin/npm npmPackages: jest: ^24.1.0 => 24.1.0
The text was updated successfully, but these errors were encountered: