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

Change snapshot header for Jest mocks to MockFunction #4835

Closed
mjesun opened this issue Nov 3, 2017 · 4 comments · Fixed by #4836
Closed

Change snapshot header for Jest mocks to MockFunction #4835

mjesun opened this issue Nov 3, 2017 · 4 comments · Fixed by #4836

Comments

@mjesun
Copy link
Contributor

mjesun commented Nov 3, 2017

Do you want to request a feature or report a bug?
That's gonna be a feature.

What is the current behavior?

Snapshots containing mocks are serialized as Object with calls + name. While this is correct, an object with an equivalent structure could make the snapshot pass (see #4829). For instance:

{
  calls: [],
  name: 'jest.fn()',
}

Would make the test pass, despite this is not a jest.fn().

What is the expected behavior?

We will change the header signature from Object to MockFunction, which will make impossible to accidentally match with an object.

@SimenB
Copy link
Member

SimenB commented Nov 3, 2017

#4836

cpojer pushed a commit that referenced this issue Nov 4, 2017
* Print jest mock fuctions as `MockFunction` in jest-snapshot

Fixes #4835

* less string concat
@JustJelena
Copy link

@mjesun which version did this change first go in, please?
I can't find #4835 or #4636 in the change log https://github.com/facebook/jest/blob/master/CHANGELOG.md

Many thanks in advance!
Jelena

@SimenB
Copy link
Member

SimenB commented Dec 3, 2018

@JustJelena in Jest 22, look for #4668 in the changelog. The change discussed in this issue landed between alphas, so conceptually it's part of #4668

@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 12, 2021
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.

3 participants