with_mock_dir {httptest2} | R Documentation |
Use or create mock files depending on their existence
Description
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.
Usage
with_mock_dir(dir, expr, simplify = TRUE, replace = TRUE)
Arguments
dir |
character string, unique folder name that will be used or created
under |
expr |
Code to run inside the context |
simplify |
logical: if |
replace |
Logical: should |
See Also
vignette("httptest2")
for usage examples.