question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
rogeliogcommented, Oct 5, 2018

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.

1reaction
rogeliogcommented, Mar 5, 2020

Jest snapshots serializers use the pretty-format package, which also lives inside the Jest repository

Here are some links that might be useful.

Let me know if that doesn’t help and I’m happy to provide more specific details

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found