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: vignettes/snapshotting.Rmd
+4-4
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ set.seed(1014)
16
16
```
17
17
18
18
The goal of a unit test is to record the expected output of a function using code.
19
-
This is a powerful technique because because not only does it ensure that code doesn't change unexpectedly, it also expresses the desired behaviour in a way that a human can understand.
19
+
This is a powerful technique because not only does it ensure that code doesn't change unexpectedly, it also expresses the desired behaviour in a way that a human can understand.
20
20
21
21
However, it's not always convenient to record the expected behaviour with code.
22
22
Some challenges include:
@@ -151,7 +151,7 @@ Within a test, each snapshot expectation is indented by four spaces, i.e. as cod
151
151
152
152
### Interactive usage
153
153
154
-
Because the snapshot output uses the the name of the current test file and the current test, snapshot expectations don't really work when run interactively at the console.
154
+
Because the snapshot output uses the name of the current test file and the current test, snapshot expectations don't really work when run interactively at the console.
155
155
Since they can't automatically find the reference output, they instead just print the current value for manual inspection.
156
156
157
157
## Other types of snapshot
@@ -169,9 +169,9 @@ Since they can't automatically find the reference output, they instead just prin
169
169
But that doesn't work for all file types --- for example, what happens if you want to snapshot an image?
170
170
`expect_snapshot_file()` provides an alternative workflow that generates one snapshot per expectation, rather than one file per test.
171
171
Assuming you're in `test-burger.R` then the snapshot created by `expect_snapshot_file(code_that_returns_path_to_file(), "toppings.png")` would be saved in `tests/testthat/_snaps/burger/toppings.png`.
172
-
If a future change in the code creates a a different file it will be saved in `tests/testthat/_snaps/burger/toppings.new.png`.
172
+
If a future change in the code creates a different file it will be saved in `tests/testthat/_snaps/burger/toppings.new.png`.
173
173
174
-
Unlike `expect_snapshot()` and friends, `expect_snapshot()` can't automatically provide an automatic diff when the test fails.
174
+
Unlike `expect_snapshot()` and friends, `expect_snapshot_file()` can't provide an automatic diff when the test fails.
175
175
Instead you'll need to call `snapshot_review()`.
176
176
This launches a Shiny app that allows you to visually review each change and approve it if it's deliberate:
Copy file name to clipboardExpand all lines: vignettes/third-edition.Rmd
+1-1
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,7 @@ You'll have to explicit ignore them with `supressMesssages()`, or if they're imp
100
100
101
101
### waldo
102
102
103
-
Probably the the biggest day-to-day difference (and the biggest reason to upgrade!) is the use of [`waldo::compare()`](https://waldo.r-lib.org/reference/compare.html) inside of `expect_equal()` and `expect_identical()`.
103
+
Probably the biggest day-to-day difference (and the biggest reason to upgrade!) is the use of [`waldo::compare()`](https://waldo.r-lib.org/reference/compare.html) inside of `expect_equal()` and `expect_identical()`.
104
104
The goal of waldo is to find and concisely describe the difference between a pair of R objects, and it's designed specifically to help you figure out what's gone wrong in your unit tests.
0 commit comments