jest-emotion and snapshot-diff not playing nice
See original GitHub issueCurrent behavior:
jest-emotion
doesn’t appear to work as a serializer for snapshot-diff
. Tried various permutations of the config and the test setup but it doesn’t play nice. It’s unclear if this is a problem with the docs or an API thing.
To reproduce:
Minimal repo: https://github.com/DarkPurple141/jest-emotion-typescript-minimal/tree/master
- install dependencies and run jest
Expected behavior:
Environment information:
react
version: 16.9emotion
version: 10.0.28
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Jest Suite Doesn't Output Color For The Snapshot Diff
When we run our test, Jest automatically generates a snapshot of the rendered component and puts it inside the __tests__ directory. If we...
Read more >The snapshot-diff from jest-community - GithubHelp
Jest mock names not honoured in resulting snapshot. I've encountered an issue where taking a snapshot diff doesn't maintain a mock functions name....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve looked very quickly and some of my findings are:
snapshot-diff
is not using by default builtin serializers, it only uses a wrapper around react serializer which is based on React elements, react-test-renderer, etc. So it doesn’t work with JSDOM output{ test, print }
interface when the new API is using{ test, serialize }
, this makes it impossible to reuse all current jest’s builtin serializers because they are written using the new API.Ok, I’ve managed to see what’s your issue but it wasn’t at all apparent where I should look for it as you have provided 3 different test files without pointing to a specific problem.
app.test.tsx
gave me an answer but this was the last place I was looking into.It seems that
toMatchDiffSnapshot
just doesn’t run through added custom serializers: https://github.com/jest-community/snapshot-diff/blob/2d81e0a5ca04f682cebf13cf94c9dd369d4c81c7/src/index.js#L89 https://github.com/jest-community/snapshot-diff/blob/2d81e0a5ca04f682cebf13cf94c9dd369d4c81c7/src/index.js#L37 but it seems that you maybe can tell it to run through by usingsetSerializers
: https://github.com/jest-community/snapshot-diff/blob/2d81e0a5ca04f682cebf13cf94c9dd369d4c81c7/src/index.js#L113I hope this answers your question, if not - feel free to comment back but I’m going to close this right now as I think it got answered.