Skip to content
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

Mocha-test-runner executes tests that should not be executed #4766

Open
mcdr2k opened this issue Feb 29, 2024 · 4 comments · May be fixed by #4874
Open

Mocha-test-runner executes tests that should not be executed #4766

mcdr2k opened this issue Feb 29, 2024 · 4 comments · May be fixed by #4874
Labels
🐛 Bug Something isn't working

Comments

@mcdr2k
Copy link

mcdr2k commented Feb 29, 2024

Summary

Mocha-test-runner may execute tests for a mutant that do not cover that mutant (even though coverageAnalaysis is enabled). Assume that the test titled 'some test' covers mutant x. Then, at the moment, a test titled 'some test that does not cover x' is also executed. In fact, every test that starts with the string 'some test' is executed.

It is unclear whether other test-runners have the same issue.

** Cause & possible Fix **
caused by mocha-test-runner: const metaRegExp = testFilter.map((testId) => `(${escapeRegExp(testId)})`).join('|');

This can be fixed by appending a dollar sign after the escaped regex: const metaRegExp = testFilter.map((testId) => `(${escapeRegExp(testId) + '$'})`).join('|');

Stryker config

This bug was found during development with stryker-js, meaning that all configurations are the same as the current master branch of stryker-js.

@mcdr2k mcdr2k added the 🐛 Bug Something isn't working label Feb 29, 2024
@nicojs
Copy link
Member

nicojs commented Feb 29, 2024

Great find 👏

How about the start of the regex? I would expect a ^ as well as a $.

@mcdr2k
Copy link
Author

mcdr2k commented Feb 29, 2024

Yes you are right, both caret and dollar sign are necessary. The possible fix for mocha-test-runner would then be: const metaRegExp = testFilter.map((testId) => `(^${escapeRegExp(testId)}$)`).join('|');

@nicojs
Copy link
Member

nicojs commented Mar 9, 2024

Did you want to fix this one @mcdr2k ?

@mcdr2k
Copy link
Author

mcdr2k commented Mar 13, 2024

Yes, I would like to fix this one. However, at the moment I am investigating an issue that could be related to this.

@mcdr2k mcdr2k linked a pull request May 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants