You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,19 @@ func TestMain(m *testing.M) {
51
51
52
52
Once included, if the update `-u` flag is used when running tests, any snapshot that is no longer in use will be removed. Note: if a single test is run, pruning _will not occur_.
53
53
54
+
Alternatively `CleanupOrFail` can be used to fail a test run if a snapshot needs cleaning up but the `-u` flag wasn't given (and it's not a single-test run):
55
+
56
+
```go
57
+
funcTestMain(m *testing.M) {
58
+
if m.Run() == 0 {
59
+
iferr:= abide.CleanupOrFail(); err != nil {
60
+
fmt.Fprintln(os.Stderr, err.Error())
61
+
os.Exit(1)
62
+
}
63
+
}
64
+
}
65
+
```
66
+
54
67
## Snapshots
55
68
56
69
A snapshot is essentially a lock file for an http response. Instead of having to manually compare every aspect of an http response to it's expected value, it can be automatically generated and used for matching in subsequent testing.
@@ -105,4 +118,4 @@ To write snapshots to a directory other than the default `__snapshot__`, adjust
0 commit comments