fix: `bigint` cause error (#15702)

This commit is contained in:
Aleksei Bondarenko 2025-07-04 02:59:37 +03:00 committed by GitHub
parent f4296d2bc8
commit a3d1e2eb4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,9 @@
## main
### Fixes
- `[expect]` Fix `bigint` error ([#15702](https://github.com/jestjs/jest/pull/15702))
## 30.0.4
### Features

View File

@ -328,6 +328,15 @@ describe('toThrow', () => {
});
});
test('isNot false, cause is bigint', () => {
jestExpect(() => {
throw new Error('Message', {cause: 0n});
}).toThrow({
cause: 0n,
message: 'Message',
});
});
test('isNot false, cause is object', () => {
jestExpect(() => {
throw new Error('Message', {

View File

@ -486,7 +486,10 @@ function createMessageAndCause(error: Error) {
if (seen.has(value)) return;
seen.add(value); // stop circular references
}
return value === undefined ? String(undefined) : value;
if (typeof value === 'bigint' || value === undefined) {
return String(value);
}
return value;
});
}