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.

Question/Feature request.

Hey I’m noticing issues with Snapshots ran on differing operating systems (see #6102 and #6113 as examples).

Is it possible to specify the percentage a snapshot should match on? For example match 90% of the snapshot, allowing for 10% error rate which we don’t care about.

If not, and this is something people don’t want to add, perhaps a new matcher should be created to deal with whitespace, tabs and newlines etc.

test('ignores whitespace etc', () => {
  expect(`\t hello world\n

                    foo
bar
baz
`).toMatchSnapshotIgnoringXXX();
});
↓↓↓ snapshot ↓↓↓
exports[`ignores whitespace etc 1`] = `
"	 hello world


                      foo
  bar
  baz
  "
`;

This snapshot could be stored with the whitespace etc to keep it human readable but when compared to the value both could be normalised.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, May 6, 2018

@mattphillips mind changing this issue (or opening up a new one) to be about exposing toMatchSnapshot to custom matchers?

0reactions
github-actions[bot]commented, May 12, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly. A typical snapshot test...
Read more >
Snapshot Testing: Benefits and Drawbacks - SitePen
Snapshot testing is a type of “output comparison” or “golden master” testing. These tests prevent regressions by comparing the current ...
Read more >
What is a snapshot test? - Lara Schenck
A snapshot test is a specific kind of technique for regression testing, that is, tests that make sure changes to a code-base do...
Read more >
GitHub - pointfreeco/swift-snapshot-testing
Dozens of snapshot strategies. Snapshot testing isn't just for UIView s and CALayer s. Write snapshots against any value. Write your own snapshot...
Read more >
Snapshot Testing - objc.io
Snapshot tests are run at the same time as the rest of your tests. They don't have to run as another test scheme....
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