-
Notifications
You must be signed in to change notification settings - Fork 250
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
fix(jest-runner): Support multi project jest-configs #2780
fix(jest-runner): Support multi project jest-configs #2780
Conversation
fcdae68
to
7d35190
Compare
This mimics behaviour of jest - if you want to use projects, you need to pass the config by file. This teaches stryker to do the same - if you set explicit config path in jest config, that gets passed into jest and voila, multi project jest works :) https://github.com/swist/stryker-test is the minimum reproducible example repo for this
7d35190
to
455e170
Compare
This looks like it fell victim to unrelated test flake, jasmine runner tests have sometimes been running out of heap on my local host too. [edit] it was a real failure, should be fixed now |
Turns out that we can also make projects play nice with stryker-modified jest configs. There are two requirements however - they need to have rootDir set in jest CLI args and we need to make sure that the filename ends in .json so that require doesn't trip over
46f9cc6
to
2828fcb
Compare
Thanks, @swist 🐱👤, I will need some time to look into this in detail. |
TL;DR - jest needs to read config from file to behave correctly with multi project. This takes stryker modified jest-config and writes it to a specially suffixed |
Ok, thanks for the explanation. I've started looking into this. Am I allowed to say: I hate jest for having this A feature like this deserves its very own "e2e" test project. I was trying to base it on your project, but there seems to be a problem. When I run
|
Ok, I've added an e2e test. As for the solution direction, I don't like test runners just writing files to the sandbox. This is problematic for a couple of reasons:
I've looked through jest's |
I've opened jestjs/jest#11213 |
Agreed and I thought I had a solution that didn't need this (just pass the original config) but then it turned out that striker sometimes rewrites the jest configs :(
Is this strictly true? In my testing I get ~(# cpu cores/2)-1 sandboxes. Because the stryker modifications to the config are idempotent I figured it's just fine to timestamp them per sandbox instance
I guess the solution could be to namespace these configs by stage? Although I'd guess that because each stage generates a new, unique(ish) config that gets passed on, it doesn't really matter that much
Is there any way to add a clean-up hook after each run? Stryker already leaves the sandboxes behind, so from my perspective it wasn't a big deal
The issue at jest has been open for a couple of years now, unlikely they will fix it :) |
Only 28 days, right? 😉 I've opened a PR, let's see what they do with it. I agree that it is a small hack, but in my experience, hacks like these tend to linger and pile up. With all respect, but once it is in we will have to maintain it for as long as Jest is being used. Let's hope they agree to merge the PR.
It shouldn't. After a successful run, it is cleaned. Also with |
Hmm, maybe it's the failed runs that leave sandboxes behind. Jest have known about the problem since 2018: jestjs/jest#7415 It's linked from stryker already (#2574) |
Cool, all the more reasons we should be able to get this merged in jest 💪 |
My PR fix just got merged in Jest 🃏 jestjs/jest#11307 So it should simply work out-of-the-box from the next release. Closing this PR |
Hey @nicojs . Thanks for contributing to this project. and what I have in test path in my jest.config: It injects mutants to all source files successfully and then run the tests and fails with the following error: Could you set up a similar project and try to debug and fix such an issue? P.S here is my stryker.config
And jest.config |
Thanks for coming back with this. I'll reopen this issue. We should add an e2e test for jest with a |
Ooops, reopened the PR instead of the issue 😅 |
This mimics behaviour of jest - if you want to use projects,
you need to pass the config by file. This teaches stryker to do
the same - if you set explicit config path in jest config,
that gets passed into jest and voila, multi project jest works :)
https://github.com/swist/stryker-test is the minimum reproducible
example repo for this
Gives a sensible-ish workaround for #2574 until jest fix their stuff (and it doesn't look like they will, the issue was open for a couple of years, so would be great to merge this instead!)