-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
BigInt are not supported in .deep.equal() #1623
Comments
As a workaround for anyone encountering this issue, you add this to your runner pre-run script: // eslint-disable-next-line no-extend-native -- Chai does not support BigInt serialisation.
Object.defineProperty(
BigInt.prototype,
"toJSON",
{
writable: false,
enumerable: false,
configurable: false,
value: function(): string
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/restrict-template-expressions
return `${this.toString()}n`;
},
}
); It's unclean but at least it works. |
i tried the exact code in the first post and it seems to work fine for me could you give some more info, like how you're building and running this test? e.g. do you use ts-node or do you run the built JS? do you output commonjs or esm? etc etc |
Hey! Thanks for your answer. To help understand this problem, I will create a repository aiming to replicate the issue with a few dependencies and code as possible and post it here. That way I will either find my own mistake or save you time instead of making you blindly look for the problem. |
Hey!
I am using the latest version of Chai and it appears if you try to deep equal an object that has a property of type
BigInt
, Chai will throw an Error.Here is a code sample that should reproduce the issue (TypeScript):
Support for BigInt was apparently added a while back but it seems it no longer works or
deep.equal
did not work.The text was updated successfully, but these errors were encountered: