-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snapshot testing #6115
Comments
@mattphillips would this be solved by #5847? With that you could do: test('ignores whitespace etc', () => {
expect(`\t hello world\n
foo
bar
baz
`).toMatchSnapshot(
expect.stringMatching(/hello world/),
); Another option we've discussed - exposing toMatchSnapshot to custom matchers so you could do something like: expect.extend({
toMatchSnapshotTrimmed: (received) => {
return this.toMatchSnapshot(received.trim());
}
}) |
@rickhanlonii #5847 looks very cool and would certainly help with this! Whats happening with the proposal is it currently being worked on? I think exposing |
@mattphillips mind changing this issue (or opening up a new one) to be about exposing |
Closed in favour of #6144 |
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. |
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.
This snapshot could be stored with the whitespace etc to keep it human readable but when compared to the value both could be normalised.
The text was updated successfully, but these errors were encountered: