Closed PaulRBerg closed 5 years ago
Doing more debugging, I delved in some really spooky results:
const assertion = (await this.token.totalSupply()).should.be.bignumber;
console.log(
"(await this.token.totalSupply()).should.be.bignumber",
assertion
);
console.log(
"assertion.equal",
assertion.equal
);
console.log(
"assertion.equal(100)",
assertion.equal(100)
);
Output is:
(await this.token.totalSupply()).should.be.bignumber Assertion {
__flags:
{ ssfi: [Function: proxyGetter],
lockSsfi: undefined,
object: BigNumber { s: 1, e: 2, c: [Array] },
message: null,
bignumber: true } }
assertion.equal function () { [native code] }
...
TypeError: expected.equals is not a function
at Proxy.<anonymous> (test/base/chai-bignumber.js:57:18)
at Proxy.<anonymous> (test/base/chai-bignumber.js:45:16)
at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33)
at Context.<anonymous> (test/base/ERC20.test.js:31:19)
at process._tickCallback (internal/process/next_tick.js:68:7)
This is weird because the log just right before that says that equals
is a function with "native code".
Yup, same error happens when running the examples in the README:
var result = new BigNumber('100000000000000000').plus(1);
var expected = '100000000000000001';
result.should.be.bignumber.equal(expected);
This happens because of a breaking change in BigNumber that wasn't reflected in chai-bignumber.
equals
was renamed to isEqualTo
and chai-bignumber needs to be updated.
https://github.com/MikeMcl/bignumber.js/blob/master/CHANGELOG.md#600
Please update to the latest version.
This is awesome, thank you!
Using:
• chai 4.2.0 • truffle 5.0.0-beta.1 • bignumber.js 8.0.1
I also tried chai 4.1.2, truffle 4.1.14 and 4.1.13 and also replaced bignumber.js with bn.js. Always the same error when doing:
should.be.bignumber.equal(100)