jestjs/jest
Vedi su GitHub[Bug]: it.each doesn't support BigInt, complaining "TypeError: Do not know how to serialize a BigInt"
Open
#12.827 aperta il 9 mag 2022
:bug: BugHelp WantedPinned
Metriche repository
- Star
- (45.361 star)
- Metriche merge PR
- (Merge medio 11g 22h) (11 PR mergiate in 30 g)
Descrizione
Version
28.0.2
Steps to reproduce
Following test will end up with an error (see section "Action Behaviour"), no matter the matcher is passed or failed.
describe("error", () => {
it.each([
[1n, 2n, 3n]
])("test", (a, b, c) => {
expect(a + b).toBe(c);
});
});
Also, Jest prints out such error whenever a test is failed (without it.each).
describe("error", () => {
it("print annoying message when a test failed.", () => {
expect(1n + 3n).toBe(10n);
});
});
But oddly, if you write matcher outside it(...) functions, Jest will not print out the error message - it will print out messages of failed tests:
describe("write matcher outside it(...)", () => {
expect(1n + 3n).toBe(10n);
});
● Test suite failed to run
expect(received).toBe(expected) // Object.is equality
Expected: 10n
Received: 4n
12 |
13 | describe("write matcher outside it(...)", () => {
> 14 | expect(1n + 3n).toBe(10n);
| ^
15 | });
at toBe (chapter.16-greedy-algorithm/exercises/__tests__/16.2-7.js:14:21)
at describe (chapter.16-greedy-algorithm/exercises/__tests__/16.2-7.js:13:1)
Expected behaviour
This error should not shows up.
Actual behavior
Complained that:
● 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:33:19)
Additional context
No response
Environment
System:
OS: Windows 10 10.0.19042
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Binaries:
Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.13.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: ^28.0.2 => 28.0.2