22 Caching HTTP requests

Record HTTP calls and replay them

22.1 Package documentation

Check out https://docs.ropensci.org/vcr/ for documentation on vcr functions.

22.3 Basic usage

https://docs.ropensci.org/vcr/articles/vcr.html ## vcr enabled testing {#vcr-enabled-testing}

22.3.1 check vs. test

TLDR: Run devtools::test() before running devtools::check() for recording your cassettes.

When running tests or checks of your whole package, note that you’ll get different results with devtools::check() (check button of RStudio build pane) vs. devtools::test() (test button of RStudio build pane). This arises because devtools::check() runs in a temporary directory and files created (vcr cassettes) are only in that temporary directory and thus don’t persist after devtools::check() exits.

However, devtools::test() does not run in a temporary directory, so files created (vcr cassettes) are in whatever directory you’re running it in.

Alternatively, you can run devtools::test_file() (or the “Run test” button in RStudio) to create your vcr cassettes one test file at a time.

22.3.2 CI sites: GitHub Actions, Appveyor, etc.

Refer to the security chapter.