Skip to content

Make existing Jest matchers available in expect.extend #3139

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

Closed
akxcv opened this issue Mar 14, 2017 · 3 comments
Closed

Make existing Jest matchers available in expect.extend #3139

akxcv opened this issue Mar 14, 2017 · 3 comments

Comments

@akxcv
Copy link

akxcv commented Mar 14, 2017

Feature request: it would be really convenient to be able to build custom matchers on top of existing ones. In my project I really needed to use expect(x).toEqual(y) in my custom matcher. I was able to do this by using jasmine.matchersUtil.equals. However, this is not documented anywhere in Jest docs. Is this the intended way? Or should we add this to this.utils?

What is the current behavior?

To to use toEqual matcher in expect.extend, one needs to call jasmine.matchersUtil.equals.

What is the expected behavior?

The user should be able to do something like this.utils.equals and this has to be documented. If the jasmine.matchersUtil is actually the intended behaviour, it needs to be documented in expect.extend section.

@cpojer
Copy link
Member

cpojer commented Mar 15, 2017

See #2547.

@cpojer cpojer closed this as completed Mar 15, 2017
@tncbbthositg
Copy link

tncbbthositg commented Jul 7, 2017

I ran across this issue looking for an equivalent to jasmine.objectContaining. I know there's an expect.objectContaining matcher, but I don't feel like I want to new that up and call asymmetricMatch on it to do an asymmetric object comparison (per the discussion on #2547).

I don't want to make an expectation in my custom matcher; I just want to test whether the expected properties are among the actual properties.

But then I saw that jasmine is in the global scope . . . (which is why I think this comment is relevant on this issue rather than the other).

What is the relationship between Jest and Jasmine? Should we expect the jasmine object to continue to be available? Should I use jasmine.objectContaining in lieu of expect.objectContaining?

@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 May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants