This context will switch the .mockPaths() to tests/testthat/dir
(and then resets it to what it was before).
If the tests/testthat/dir folder doesn't exist, capture_requests() will
be run to create mocks.
If it exists, with_mock_api() will be run.
To re-record mock files, simply delete tests/testthat/dir and run the test.
Arguments
- dir
character string, unique folder name that will be used or created under
tests/testthat/- expr
Code to run inside the context
- simplify
logical: if
TRUE(default), plain-text responses with status 200 will be written as just the text of the response body. In all other cases, and whensimplifyisFALSE, thehttr2_responseobject will be written out to a .R file usingbase::dput().- replace
Logical: should
dirreplace the contents of.mockPaths()(default) or be added in front of the existing paths? The default behavior here is the opposite of.mockPaths()so that the tests inside ofwith_mock_dir()are fully isolated.
See also
vignette("httptest2") for usage examples.