Skip to content

Commit

Permalink
encourage collapsing expectation to single line (closes #48)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Oct 21, 2024
1 parent 32f4f57 commit 063ad6c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions inst/prompts/testthat-replace.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ expect_snapshot(
)
```

Often, when converting to snapshots, the total number of characters will be under 80 once the regular expression is removed. In that case, collapse all of the error expectation onto one line.

``` r
# before:
expect_error(
some_function_call(),
"A regex on a newline that has many characters."
)

# good:
expect_snapshot(error = TRUE, some_function_call())

# bad:
expect_snapshot(
error = TRUE,
some_function_call()
)
```

Sometimes there's no regex argument. The solution is the same in that case:

``` r
Expand Down

0 comments on commit 063ad6c

Please sign in to comment.