stryker-js icon indicating copy to clipboard operation
stryker-js copied to clipboard

Initial test run `runInBand` in jest

Open Djaler opened this issue 2 years ago • 10 comments

Summary

I found out that Stryker runs jest with runInBand: true option. And this makes initial test run very very slow for me, and it is fails with timeout error because of this. What is the reason to run tests in band?

Djaler avatar Oct 27 '21 13:10 Djaler

Stryker needs it to run in band, so coverage per test can be reported back to Stryker.

During mutation testing, Stryker already runs multiple test runners in parallel, so adding more parallelism would not improve performance. In fact, it would decrease it.

Strange that you're running in a timeout. What exactly do you mean by that? Does the dry run timeout?

nicojs avatar Oct 27 '21 15:10 nicojs

Ah sorry, I see you specified "initial run" in the title.

If you run into a timeout then you can use dryRunTimeoutMinutes.

How long does a normal unit test run with jest take?

nicojs avatar Oct 27 '21 18:10 nicojs

Normal run: 68 s Run in band: 621s Both runs after clear cache

Djaler avatar Oct 27 '21 18:10 Djaler

Also, can I bump #1655 here? :D

Djaler avatar Oct 27 '21 18:10 Djaler

Sometimes, when working on tests for peace of code, I want to regularly rerun stryker to check coverage. But I can't wait 10 minutes for initial tests run each time, this is too long

Djaler avatar Oct 27 '21 18:10 Djaler

I think #1655 would solve the use case where you simply want to run Stryker with Jest on a single file in a large code base. I'll add the hacktoberfest label to it. Seems to do wonders these days 😉

nicojs avatar Oct 27 '21 19:10 nicojs

@nicojs if I understand correctly, runInBand is not needed when coverageAnalysis: 'off', right?

Djaler avatar Oct 31 '21 20:10 Djaler

@nicojs would you be open to add an optional parameter to the CLI so that one could do: stryker run path/to/my-test.js ?

I see @Djaler's PR improves DX for a mutant check of a subset of files and I think this would be the icing on the cake.

Currently it's <command> [options] [configFile] so we'd have to think how (or if) we can remain backwards compatible.

Edgpaez avatar Nov 01 '21 03:11 Edgpaez

@Edgpaez that would be very breaking and I don't know if it would add a lot.

My guess is that you mean stryker run path/to/my-source-file-to-mutate.js rather than my-test.js. You can see how this might be confusing without an option flag.

Also, what you want is already supported with the option flag -m: stryker run -m path/to/my-source-file-to-mutate.js.

Please open a separate issue if you want to discuss it further.

nicojs avatar Nov 01 '21 05:11 nicojs

@nicojs if I understand correctly, runInBand is not needed when coverageAnalysis: 'off', right?

That would be true. If you want, you can create a PR for that case. However, I'm not a big fan. I'm thinking of removing the option to turn off coverage analysis altogether and simply always force "perTest". It would simplify StrykerJS's usage and inner workings a lot.

nicojs avatar Nov 26 '21 12:11 nicojs

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 26 '22 17:11 stale[bot]