-
Notifications
You must be signed in to change notification settings - Fork 208
Open
Description
chai.js has cool API that allows for checking if two values (including floats) are close to each other.
For example, you can't realy check
expect(0.1+0.2).to.be(0.3)
because there is always rounding error in floating point calculation.
So instead in chai you write
let EPS = 1e-5;
expect(0.1+0.2).to.be.closeTo(0.3, EPS)
This function is oneliner, so this totaly fits "minimalistic" idea.
I know that I can use something like
expect(abs(f1-f2)).to.be.below(EPS)
but this is not very intuitive for reader that my intention is just check that f1 and f2 are just close to each other.
kengorab and tsheaff
Metadata
Metadata
Assignees
Labels
No labels