chai-bignumber
chai-bignumber copied to clipboard
should works, expect doesn't
Here's the example from the README:
var result = new BigNumber("100000000000000000").plus(1);
var expected = "100000000000000001";
result.should.be.bignumber.equal(expected);
It works fine. But, if I replace the last line with:
expect(result).to.be.bignumber.equal(expected);
I get the following error:
Error: Invalid Chai property: bignumber
Versions:
• node 10.15.3 • [email protected] • [email protected]
any updates? same issue here
Is chai-bignumberbeing loaded before use?
I am unable to reproduce using the following example:
var BigNumber = require('bignumber.js');
var chai = require('chai');
var expect = require('chai').expect
chai.use(require('chai-bignumber')(BigNumber));
var result = new BigNumber("100000000000000000").plus(1);
var expected = "100000000000000001";
expect(result).to.be.bignumber.equal(expected);
Any update? Weird, for my setup,
this works:
var expect = require("../../utils/chai-setup").expect;
but this doesn't work:
import { expect } from "../../utils/chai-setup";
In "../../utils/chai-setup" I have:
import chaiModule from "chai"; import BN from "bn.js"; chaiModule.use(require("chai-bn")(BN)); export = chaiModule;
Hey @colinsteidtmann, I have not found a solution for this package, but I can wholeheartedly recommend switching to TypeScript. I made the switch in the meantime and it has enhanced my development productivity.
See my solidity-template, which comes with Waffle - a testing framework for Ethereum contracts that includes the functionality implemented by chai-bignumber.
Hey Paul, that's funny, I'm actually using your template! You just didn't have any examples working with bignumbers so I went looking for a solution. I'll check out chai-bignumber. I love your repo by the way. I customized it a bit with hardhat-deploy and some chainlink libraries.
@colinsteidtmann can you provide a complete example?
Hey Paul, that's funny, I'm actually using your template
Oh haha!
You just didn't have any examples working with bignumbers so I went looking for a solution.
You don't need a package like chai-bignumber if you're using my template. Waffle has built-in support for BigNumber matchers.