'Chai should be bignumber equal doesn't work

I am requireing chai like this

const BigNumber = web3.BigNumber;
require('chai').use(require('chai-bignumber')(BigNumber)).should();

and during test

let balance = await contract.balanceOf(accountToReceive);
should.be.bignumber.eql(countToSend); //works fine
ownerBalance = await contract.balanceOf(owner);
should.be.bignumber.equal(settings.initialSupply.mul(utils.toBN(10).pow(_decimals)).sub(countToSend)); // gives en error

Error code is

AssertionError: expected <BN: 94e47b8d68171533ffff9c> to equal <BN: 94e47b8d68171533ffff9c>
     + expected - actual

     at Context.<anonymous> (test/MOS.test.js:79:33)
     at processTicksAndRejections (node:internal/process/task_queues:96:5)


Solution 1:[1]

As I've mentioned in update, you can use JS Bigint, do all your math with it and then just pass it to BN constructor as a string, like utils.toBN((1000000n * 5748553687688487n).toString())

Solution 2:[2]

I also faced the same issue with my code. I found a good solution which works for me.

Try the following:

require('chai').use(require('chai-as-promised')).should();
.use(bnChai(web3.utils.BN));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 magnagag
Solution 2 RobC