-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest
fails to generate coverage when using the testRegex
config option
#7242
Comments
I prefer number 1. It's way easier to reason with the config if the type is consistent after normalisation at all times |
Also odd we didn't have an integration test using |
We can't use My personal opinion is that configuration files should be JS files (and not JSON, even if we support reading from Probably the right moment to achieve something like this, if we wanted to, would be fixing all config inconsistencies @SimenB mentioned in #7185. |
How do we serialize now, using Since we know the shape of the config, we might consider using e.g. https://github.com/fastify/fast-json-stringify with a schema (it serializes |
We rely on Node's IPC communication for forked processes, which uses |
I don't follow how some serializer doing e.g. Alternative approach would be to write the write the config to disk somewhere (as a js file?) and pass the path that the worker calls |
You'd have an extra serializer operation which is not really needed, and consumes time. If we want to do that hoever, we can already do it and there is no need to change |
I had similar issues when I replaced |
I just remembered that @rafeca implemented the |
Yeah, it is implemented for that specific purpose. However, the It's still solvable with an const myWorker = maxWorkers === 1
? require('./worker')
: new JestWorker(require.resolve('./worker'));
await myWorker.setupConfig(config); This way you don't need any additional |
@mjesun not totally related to this, but given that the const myWorker = new JestWorker(require.resolve('./worker'), {
maxWorkers,
createNewProcesses: maxWorkers > 1, // or !config.runInBand
}); |
As a short-term fix, the easiest thing IMHO would be to implement the second solution that I suggested. It implies very short amount of changes and it will leave the logic as it was before #7209 (but without removing the feature of having an array of regexps). After we get this fixed (this issue is blocking the deploy of the new version of |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
jest@24.0.0-alpha.1
fails to generate coverage when using thetestRegex
config param. This issue has been introduced recently by #7209.To Reproduce
A very simple end to end test can be created in
e2e/__tests__/coverage_report.test.js
to reproduce the issue:Expected behavior
jest
should execute correctly when generating coverage with thetestRegex
config param.Additional information
This is the stack trace from the error:
The issue seems to be caused by the fact that the coverage is generated from a worker, so the config object gets serializer when it's sent to the worker by
jest-worker
.jest-worker
does not have any special logic to serialize regular expressions, so it defers it to Node'schild_process
logic, which converts aRegExp
into an empty object when serializing and deserializing it.Potential solutions
A couple of potential solutions that occur to me:
jest-worker
: it could even usejest-serializer
for it, which handlesRegExp
s (this may affect the performance though).testRegex
config param to an array ofRegExp
objects, but to an array of strings, and generate theRegExp
object on demand when needed (similarly than how it was done before Allow array of regexp strings for testRegex #7209).The text was updated successfully, but these errors were encountered: