-
Notifications
You must be signed in to change notification settings - Fork 22
Jest mock names not honoured in resulting snapshot #106
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
Comments
This lib uses packages from Jest: Lines 22 to 24 in b03936d
Maybe you need to make sure they're on the same version? (e.g. by Yarn |
Hi! I've used |
Interesting. Does it work as expected when doing |
Based on your last message about calling the Command: console.log(
snapshotDiff(
renderer.create(<button onClick={jest.fn().mockName('hello')}>Hello</button>),
renderer.create(<button onClick={jest.fn().mockName('world')}>World</button>)
)
); Result:
|
Did a little digging - it looks like the displaying the mock name is a custom serializer of Out of the box, the To support this, we'd need to try and wire in the custom serializer from |
Use same serializers as jest-snapshot when serializing react components rendered by react-test-renderer. Fixes jest-community#106
* Output jest mock function names in snapshot diff Use same serializers as jest-snapshot when serializing react components rendered by react-test-renderer. Fixes #106 * Add test to show output for React fragments With the React serializer updated to use `prettyFormat`, this now supports diffing React fragments when comparing a single element to multiple elements returned. Adding test to confirm output. Fixes #111 * Use jest-snapshot serializers for diff annotations Makes use of the same serializers used for printing, in the react serializer diff options which set up the A and B diff annotations.
I've encountered an issue where taking a snapshot diff doesn't maintain a mock functions name. I've outlined a simplistic example to reproduce below:
The above example shows that a standard snapshot honours the mock name, but the resulting diff does not. I'm unsure if this is a setup problem on my part but my assumption is that it's not; my understanding is that
snapshot-diff
usesreact-test-renderer
under the hood by default, so I'd have expected the mock name to have been honoured.The text was updated successfully, but these errors were encountered: