Open vostrnad opened 1 year ago
Hmm interesting. I don't think we can influence the value of JEST_WORKER_ID
inside the testing environment. It is simply always 1
, because a runner isn't aware of other runners. Would using process.env.STRYKER_MUTATOR_WORKER ?? process.env.JEST_WORKER_ID
be an option for you?
See also https://stryker-mutator.io/docs/stryker-js/parallel-workers/
Thanks for the answer, I was not aware of STRYKER_MUTATOR_WORKER
but that does solve the issue (it only requires a small update to the test suite). If it's really the case that you have no control over JEST_WORKER_ID
, feel free to close this as "not planned".
Summary
Jest uses an environment variable named
JEST_WORKER_ID
that is unique for each worker. This can be used to avoid collisions when using external resources, e.g. file system or external database. However, when using the Stryker Jest Runner, this environment variable is always 1, regardless of the concurrency setting, which potentially breaks any tests relying on it.Stryker config
Stryker environment
jest.config.json: