Optionally ignore whitespaces in snapshot tests (more flexible snapshots)
See original GitHub issue💬 Questions and Help
I teach React.js to hundreds of students, all exercises are auto-graded using Jest as testing engine. The problem is that Jest snapshots are to sensitive about spaces. If the student solution is:
<span> Hello World</span>
Instead of
<span>Hello World</span>
Jest will raise an error.
Is it possible to tell jet to be more flexible? Students constantly get stuck because they have to keep trying to match the exact solution character by character. Or maybe use the --config to tell jest to prettify the student code before testing it?
Please note that this issue tracker is not a help form and this issue will be closed.
For questions or help please see:
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
exclude Jest snapshots from git whitespace check
I want to add Jest tests using snapshots, but the snapshot files include whitespace and my tests will always fail if I remove...
Read more >Trailing spaces are stripped from .snap files causing snapshot ...
WebStorm will strip trailing spaces from lines on safe, which will cause the snapshots to fail.
Read more >JUnit 5 User Guide
Used to disable a test class or test method; analogous to JUnit 4's @Ignore . ... This allows for greater flexibility and enables...
Read more >CSS Snapshot 2021 - W3C
Abstract. This document collects together into one definition all the specs that together form the current state of Cascading Style Sheets ...
Read more >Proxmox VE Storage
As mentioned above, most file systems do not support snapshots out of the box. To workaround that problem, this backend is able to...
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 wonder if you could write a snapshot serializer that would trim the whitespaces of whenever there is a React element with text as is children.
Jest snapshots serializers use the
pretty-format
package, which also lives inside the Jest repositoryHere are some links that might be useful.
Let me know if that doesn’t help and I’m happy to provide more specific details