Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add asymmetric matcher expect.closeTo #10230

Closed
julienw opened this issue Jul 2, 2020 · 5 comments
Closed

Please add asymmetric matcher expect.closeTo #10230

julienw opened this issue Jul 2, 2020 · 5 comments

Comments

@julienw
Copy link

julienw commented Jul 2, 2020

🚀 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!

@richard-ling
Copy link

This is awesome and exactly what I've been looking for in the docs for the last day. Please merge it soon!

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@julienw
Copy link
Author

julienw commented Mar 28, 2022

dupe of #12242 which was fixed in #12243

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants