Clear and concise description of the problem
I would expect expect(1.0000011e100).toBeCloseTo(1.0000012e100, 3) to pass, but the check is for absolute difference, not relative (not a bug, as this seems intentional):
Math.abs(expected - received) < 0.005 (that is, 10 ** -2 / 2)
But for large numbers in scientific notation, having a relative difference would be handy, so I don't need to do either:
const actual = 1.0000011e100;
const expected = 1.0000012e100;
expect(actual/1e100).toBeCloseTo(expected/1e100, 3);
or
const actual = 1.0000011e100;
const expected = 1.0000012e100;
expect(actual/expected).toBeCloseTo(1, 3);
Suggested solution
Implement a new method that uses similar method to the above workarounds.
Alternative
No response
Additional context
No response
Validations
Clear and concise description of the problem
I would expect
expect(1.0000011e100).toBeCloseTo(1.0000012e100, 3)to pass, but the check is for absolute difference, not relative (not a bug, as this seems intentional):But for large numbers in scientific notation, having a relative difference would be handy, so I don't need to do either:
or
Suggested solution
Implement a new method that uses similar method to the above workarounds.
Alternative
No response
Additional context
No response
Validations