Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Later
-
None
Description
Update (2022, January 20):
Hadley's suggestion would be to move away from the
expect_snapshot({ (expect_error()) })
pattern and use one of 3 options:
- If you want to inspect the error message, use expect_snapshot(error = TRUE).
- If you want to check the class, use expect_error(class = )
- If you want to expect the message and check the class, use expect_snapshot_error(class = ).
I have being using option 1 and it seems to do most of what we want. For example, see the left_join by arg PR.
==============
This comes from Romain's suggestion to transform the test that rely on capturing a string by using a snapshot test (added in testthat's 3rd edition).
A test like:
expect_error(expression, message)
becomes
expect_snapshot({ (expect_error(expression)) })
This is probably a more general improvement we can make to our unit tests (i.e. to make more extensive use of the snapshot functionality), but I thought I'd focus on one test file to begin with.
Attachments
Issue Links
- links to