-
-
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-worker fails with "Do not know how to serialize a BigInt" in messageParent.ts
instead of showing the actual assertion error message when there are 2 or more test suite files executing in parallel
#11617
Comments
@SimenB, since you changed this part of |
Related: #10293 @kunal-kushwaha fyi |
Will look into this tomorrow! |
The choice to use JSON stock JSON serialization moving forward is not helpful. While Jest has been doing better and better with comparison support of native BigInt, the reporting of assertion failures (for me, OOB) still consistently reports an inability to serialize the bigint. With this configuration (OOB) of Jest, polyfills to fix this problem are inconsistent at best. There are new serializers that can be configured and dropped in for the one way (or even two-way if you configure them correctly) representations for error reports, for example: json-bigint |
For those of you that got here because a failing test involves some |
@gomain That actually works, but I cannot understand why turning down the maxworkers do the trick. Have you found any other solution that does not have impact on the total test time? |
@JCastrejonE serialization (currently using JSON, it does not support If only a small number of tests involve {
"scripts": {
"test:no-bigint": "jest --testPathIgnorePatterns=.*\\.bigint\\.test\\.js",
"test:bigint": "jest --maxWorkers=1 --testPathPattern=.*\\.bigint\\.test\\.js",
"test": "npm run test:no-bigint && npm run test:bigint"
}
} |
Any update? |
This is quite unplesant issue. Testing library cannot handle one of built-in language types? Srsly? Please fix it somebody! |
+1 |
1 similar comment
+1 |
Realized Prisma is returning |
I'm currently developing using NestJS, and when I encountered this issue, I looked it up and found this I was able to solve it from the following site: https://zenn.dev/serinuntius/scraps/02dfe48b643745 jest.config.ts "workerThreads": true I'm not using jest.config.ts, so I just added that code to the jest part of my package.json and that solved it. I'm not sure why this solves it, though, so if anyone knows how, I'd appreciate a reply. |
One thing to note is that your error messages on failing tests when utilizing |
Same Prisma issue as @ctsstc. It's funny how passing tests work, but then upon failing assertion it errors. I guess it's the failing test results that causes returning the data and fail serialization. And as background we have added support for bigints on our JSON.parse/stringify but this doesn't seem used by the workers then for some reason. Does someone have skills to revive @sauravhiremath attempt fixing this #11624 (comment) |
In case of a test failure, we'll see the diff instead of Jest crashing. See jestjs/jest#11617 (comment) There don't appear to be any adverse effects of enabling the option. Test failures when strictly comparing message classes are still reported correctly.
FYI Setting just the
EDIT: But We ended up switching to vitest :( Even though there's a few things I preferred in jest over vitest. |
I just ran into this issue as well. set
|
For others running into the same issue, we're trying a fix that doesn't rely on the experimental This requires patching the |
running into this issue: jestjs/jest#11617
running into this issue: jestjs/jest#11617
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. |
Link to repl or repo (highly encouraged)
Minimal reproduction repo: jest-bigint-worker-issue
🐛 Bug Report
When you have multiple test suite files executing in parallel, and some of the tests are asserting values with
bigint
numbers in them and the assertion fails, instead of showing this assertion error message,jest-worker
fails itself on attempt to serialise this value during the call to the:(in
messageParent.js
)I assume that's because
message
includesfailureDetails.matcherResult
holding the comparedbigint
values that can't be passed toprocess.send()
, as unlikeworker_threads
it does not support non-json values out of the box.To Reproduce
Steps to reproduce the behavior:
Expected behavior
You should have seen the assertion error informing you that
expect(1n).toEqual(2n);
expectation failedActual behavior
But instead you get following output due to an internal
jest-worker
error:With no details of what the actual error that
jest-worker
tried to report was intests/bigint.test.js
.envinfo
Misc
I assume that's a transport issue that user of
jest
is not supposed to be aware of. One thing I did that at least somehow solved the absence of the real message was patching thejest-worker
wrapping the call toparentProcess.send()
in atry-catch
andconsole.log
-ing the message whose serialisation failed:There is likely a number of ways how to better address this problem...
The text was updated successfully, but these errors were encountered: