I tried using the Big library but including that code just gives me an error
Error: Cannot find module 'tap'
...
So I tried to use Decimal instead. I did
npm install Decimal
And then added
const Decimal = require('decimal');
I followed the examples but I just get { Object (internal, as_int, ...) }
as my comparison when I use
const amount = 25.12
let expectedMoney;
const Decimal = require('decimal');
...
expectedMoney = new Decimal(amount * 1.1)
expect(27.63).to.equal(expectedMoney);
Error:
AssertionError: expected 27.63 to equal { Object (internal, as_int, ...) }
at Context.<anonymous> (index.test.js:19:22)
I also tried:
expect(27.63).to.equal(expectedMoney.as_int.value);
But that gives
expected 27.63 to equal 27632000000000004
And I tried
expect(27.63).to.equal(expectedMoney.toFixed(5));
But that gives
TypeError: expectedMoney.toFixed is not a function