-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Description
I'm developing smart contracts for TON using Blueprint, which relies on Jest and the @ton/sandbox
library for testing. However, I've encountered a significant issue related to Jest's handling of BigInt values. When multiple test files are executed in parallel and a test involving a BigInt fails (e.g., expect(5n).toBe(6n)
), the console output does not show the actual assertion error. Instead, it displays the message:
TypeError: Do not know how to serialize a BigInt at stringify (<anonymous>)
This issue is well-documented in Jest's GitHub repository (see issue #11617). Given that BigInt values are frequently used in smart contract testing, this behavior is quite frustrating.
The only workaround currently available is to manually update the Jest version in the Blueprint project to ^30.0.0
, but this causes warnings regarding peer dependencies:
npm warn Could not resolve dependency:
npm warn peerOptional jest@"^29.5.0" from @ton/sandbox@0.36.0
I would prefer to see this bug resolved out of the box in the @ton/sandbox
package.
Steps to Reproduce
- Create a new Blueprint project using the SimpleCounter template.
- Duplicate the template test file and rename it to
SimpleCounter1.spec.ts
. - In the duplicated test, intentionally introduce an error using BigInt. For example:
it('should reset counter', async () => { ... expect(5n).toBe(6n) });
- Run the tests. The console output will lack the reason for the test failure and will only display the message:
TypeError: Do not know how to serialize a BigInt at stringify (<anonymous>)
Environment
Node v22.13.0 (used for reproduction)
Logs or Screenshots
Incorrect behavior (out of the box):
Correct behavior (force bump Jest version to ^30.0.0
):