-
-
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
Jest 23 --config breaks create-react-app on Windows #6385
Comments
repo case: I don't know the new behavior is intended (ie the way we were doing transformIgnorePatterns was wrong) or if its a jest 23 regression. |
Only regex change I can find in the changelog is #5941. Does reverting that fix it for you? It'd be awesome if you could put together a unit (or integration) test that passes against jest 22, but fails for jest 23 |
Yep #5941 is the one that affected me. I can look into putting down a unittest after you guys figure out what the correct resolution is (see my previous comment w/ a small repo case). |
None on the core team uses windows, so we'll have to rely on the community to fix this. But having a test in the repo (skipped on windows) would be great for a potential contributor to jump in :) |
@bugzpodder This is breaking my WallabyJS test running on Windows. Is there something you did to the configuration to override the effects of #5941 on breaking Jest 23? |
@TroySchmidt I basically changed: |
Speculating... jest-config/build/index.js::readConfig() calls normalize() on incoming option values and defaults, including When normalize() sees Note that really is 5 back slashes, 2 each from each incoming back slash and 1 from the forward slash. An odd number of back slashes produces much unhappiness for a later
so path separators are okay unless they happen to have char class delimiters around them. Perhaps the wrong routine is being used? Or rather, that one routine is being called for incompatible uses. Oh, the rules wrt to '[' and ']' got changed by edd95fc and #5941 You probably do want separate routines... |
@hron thoughts? |
SyntaxError: Invalid regular expression: /[\\]node_modules[\\].+.(js|jsx|mjs)$/: Unterminated character class
|
what is the problem? My os is windows 10. |
@ThakurKarthik what errors are you seeing? You should be running |
@bugzpodder Programs generated with create-react-app are dying on Windows when/if jest is updated to 23 to fix other errors. This happens with a simple #5941 tried to fix original issue #2381 which had path members like "..../(breaks)/....", by changing a regex to try to avoid modifying an escape backslash when it was used to escape a regexp special characters. This fix now trips up on path regexes such as used by create-react-app like the above repeatedly mentioned Ahhh... got it! Key here is that The jest-regex-util line 26
should be changed to add
When I do that, the problem invalid regexp result (odd number of backslashes) More tests would be wonderful I'm sure and your being able to test on Windows would be even better. Consider testing this fix under your available platforms. |
Would you be able to provide a PR? We have CI running on appveyor, so if we can land a fix with a test we should hopefully not regress again 🙂 |
I have downgraded jest and jest-cli from v 23.1.0 to v 22.4.4.Now it's working fine.This error is only on windows platform. |
Should fix: jestjs#6385 Credits for fix go to @tshinnic
I've been thinking on this issue for quite a long time and it seems there is no easy way to fix it. Essentially this function should be very intelligent to decide if '\\' should be replaced because it's a path separator or it shouldn't if it's an escaping regex symbol (e.g. '\\]'). One of the possible solution might be to iterate over all possible replacements of the '\' and test if it's a valid regex, but it could lead to some unpredictable results. Maybe it's better to avoid using '\\' as a path separators in '*Patterns' configuration variables at all? Jest can specify this in the documentation and we can transform / to '[/\\\\]' on Windows automatically. |
For now we have to use the downgraded version |
After further consideration it seems the users uses '\\\\' to specify backslash in *Patterns. In that case the fix is possible. |
I added '--no-watchman' and it worked. |
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. |
I am trying to use Jest 23 in create-react-app@next facebook/create-react-app#4555
In particular I've found windows config to break after the upgrade.
The specific part of config being generated is https://github.com/facebook/create-react-app/blob/next/packages/react-scripts/scripts/utils/createJestConfig.js#L47
In Jest 22.4.3 the regex is
[\\\\\\\\\\\\]node_modules[\\\\\\\\\\\\].+\.(js|jsx|mjs)$|^.+\.module\.(css|sass|scss)$/
(12 slashes) in jest-runtimeIn Jest 23 the error is Invalid regular expression:
/[\\\\\]node_modules[\\\\\].+\.(js|jsx|mjs)$|^.+\.module\.(css|sass|scss)$/
Does not repo on other platforms.
The text was updated successfully, but these errors were encountered: