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:
parentProcess.send([_types().PARENT_MESSAGE_CUSTOM, message]);
(in messageParent.js)
I assume that's because message includes failureDetails.matcherResult holding the compared bigint values that can't be passed to process.send(), as unlike worker_threads it does not support non-json values out of the box.
To Reproduce
Steps to reproduce the behavior:
git clone [email protected]:klesun-productions/jest-bigint-worker-issue.git # clone minimal reproduction repo
cd jest-bigint-worker-issue
npm ci # install jest dependency
npm test # run the test that reproduces the issue
Expected behavior
You should have seen the assertion error informing you that expect(1n).toEqual(2n); expectation failed
Actual behavior
But instead you get following output due to an internal jest-worker error:
PASS tests/some-other.test.js
✓ should succeed (2 ms)
FAIL tests/bigint.test.js
● Test suite failed to run
TypeError: Do not know how to serialize a BigInt
at stringify (<anonymous>)
at messageParent (node_modules/jest-worker/build/workers/messageParent.js:42:19)
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.777 s
With no details of what the actual error that jest-worker tried to report was in tests/bigint.test.js.
envinfo
System:
OS: macOS 11.3.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 14.17.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.13 - /usr/local/bin/npm
npmPackages:
jest: ^27.0.5 => 27.0.5
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 the jest-worker wrapping the call to parentProcess.send() in a try-catch and console.log-ing the message whose serialisation failed:
try {
parentProcess.send([_types().PARENT_MESSAGE_CUSTOM, message]);
} catch (error) {
console.error('jest-worker message serialisation failed', error);
console.dir(message, {depth: 10});
throw error;
}
There is likely a number of ways how to better address this problem...
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
bigintnumbers in them and the assertion fails, instead of showing this assertion error message,jest-workerfails itself on attempt to serialise this value during the call to the:(in
messageParent.js)I assume that's because
messageincludesfailureDetails.matcherResultholding the comparedbigintvalues that can't be passed toprocess.send(), as unlikeworker_threadsit 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-workererror:PASS tests/some-other.test.js ✓ should succeed (2 ms) FAIL tests/bigint.test.js ● Test suite failed to run TypeError: Do not know how to serialize a BigInt at stringify (<anonymous>) at messageParent (node_modules/jest-worker/build/workers/messageParent.js:42:19) Test Suites: 1 failed, 1 passed, 2 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 0.777 sWith no details of what the actual error that
jest-workertried to report was intests/bigint.test.js.envinfo
Misc
I assume that's a transport issue that user of
jestis not supposed to be aware of. One thing I did that at least somehow solved the absence of the real message was patching thejest-workerwrapping the call toparentProcess.send()in atry-catchandconsole.log-ing the message whose serialisation failed:There is likely a number of ways how to better address this problem...