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

Adding asymmetric matcher expect.closeTo #12242

Closed
Biki-das opened this issue Jan 15, 2022 · 2 comments · Fixed by #12243
Closed

Adding asymmetric matcher expect.closeTo #12242

Biki-das opened this issue Jan 15, 2022 · 2 comments · Fixed by #12243

Comments

@Biki-das
Copy link
Contributor

🚀 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

@Biki-das
Copy link
Contributor Author

@SimenB what are your thoughts on this?

@SimenB SimenB linked a pull request Feb 5, 2022 that will close this issue
@github-actions
Copy link

github-actions bot commented Mar 8, 2022

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 Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant