Snapshot testing
See original GitHub issueQuestion/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:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top 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 >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
@mattphillips mind changing this issue (or opening up a new one) to be about exposing
toMatchSnapshot
to custom matchers?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.