You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although BigInts are a stage 3 proposal, they are supported in Node 10 and V8 6.3. One of the quirks of BigInt is that it's not JSON serializable. When attempting to compare two BigInts, chai uses the JSON, which produces the wrong result.
Here's a minimum example, which works on Node 10 and Chai 4.1.2
>letchai=require('chai')>chai.should()>1n.should.equal(1n)// ↪AssertionError: expected {} to equal {}>1234n.should.equal(123n)// ↪AssertionError: expected {} to equal {}
I think Chai should check if typeof returns 'bigint'
>typeof123n// ↪'bigint'
And use equality to make the comparison in that case (and toString()) instead of JSON serialization.
I'm happy to take a look at this if this is something that others think Chai should support.
The text was updated successfully, but these errors were encountered:
no2chem
changed the title
BigInt are not properly supported by assertions
BigInts are not properly supported by assertions
Sep 14, 2018
We'll definitely make sure to tackle bigints in the next version of chai! We've added this to our Roadmap https://github.com/chaijs/chai/projects/2! We'll be releasing chai 5 soon, but for now I'll close this issue because it is tracked on our roadmap.
Although BigInts are a stage 3 proposal, they are supported in Node 10 and V8 6.3. One of the quirks of BigInt is that it's not JSON serializable. When attempting to compare two BigInts, chai uses the JSON, which produces the wrong result.
Here's a minimum example, which works on Node 10 and Chai 4.1.2
I think Chai should check if typeof returns 'bigint'
And use equality to make the comparison in that case (and toString()) instead of JSON serialization.
I'm happy to take a look at this if this is something that others think Chai should support.
The text was updated successfully, but these errors were encountered: