-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Description
π Feature Proposal
There is a matcher toBeCloseTo
that's super useful to assert floats. But when these floats are inside objects or arrays we can't use it directly. Therefore it would be useful to have an asymmetric matcher so that we can use toEqual
with it, eg:
expect(value).toEqual([
{ start: expect.closeTo(5.3), end: expect.closeTo(5.8) }
]);
It makes sense to be included in Jest core because of the existing matcher toBeCloseTo, that would be more consistent.
Thanks!.
Motivation
t would be useful to have an asymmetric matcher so that we can use toEqual
with it, eg:
expect(value).toEqual([
{ start: expect.closeTo(5.3), end: expect.closeTo(5.8) }
]);
Example
it used the same algorith in toBeCloseTo
Pitch
toBeCloseTo
is super useful to assert floats. but when these floats are inside of any array or object, we can access it directly. and it should belong to jest core platform