-
Notifications
You must be signed in to change notification settings - Fork 242
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
Invalid regular expression in initial test run on Node 18 #3579
Comments
Hi @ericcornelissen 🙋♂️ thanks for opening this issue. This is a neat little bug. Apparently the Regex mutator we use (⚔ weapon-regex) is mutating this incorrectly. I've opened an issue there. In the meantime, you can workaround it by disabling mutating these regexes with a comment: export function escapeArgBash(arg) {
// Stryker disable next-line Regex: Results in invalid mutant
return arg.replace(/\u{0}/gu, "");
} |
After reading through stryker-mutator/weapon-regex#163 I think a better workaround is to switch from a unicode regex to a "normal" regex and use export function escapeArgBash(arg) {
- // Stryker disable next-line Regex: Results in invalid mutant
- return arg.replace(/\u{0}/gu, "");
+ return arg.replace(/\u0000/g, "");
} |
This PR adds support for unicode regexes. I.e.: `/\u{0}/gu` isn't mutated to `/\u/gu` (which is invalid). * update dependency weapon-regex to v1 to support unicode regexes, see stryker-mutator/weapon-regex#165 * pass regex flags argument to weapon-regex. Closes #3579 Co-authored-by: Hugo van Rijswijk <git@hugovr.nl>
Summary
When running Stryker on one of my projects using Node 18 (using this branch) I'm getting an unexpected error during the initial test run. In particular, I'm getting the following error:
This error is related to the use of a regular expression of the form
/\u{0}/gu
in several places (example). Inspecting the files in Stryker's temp directory does reveal regular expressions of the form/\u/gu
, which is indeed invalid syntax. However, it is not clear to me how such an invalid regular expression ends up in the code generated by Stryker.A notable detail, I'm encountering this bug only on Node 18 (I tried 18.0.0 and 18.13.0) but not earlier versions (I tried 16.13.1, but I've been using Stryker on Node 16 in this project for a while now).
Stryker config
Test runner config
I'm using AVA without any configuration.
Stryker environment
Test runner environment
Your Environment
Add stryker.log
stryker.log
The text was updated successfully, but these errors were encountered: