Package: httptest2 1.2.2
httptest2: Test Helpers for 'httr2'
Testing and documenting code that communicates with remote servers can be painful. This package helps with writing tests for packages that use 'httr2'. It enables testing all of the logic on the R sides of the API without requiring access to the remote service, and it also allows recording real API responses to use as test fixtures. The ability to save responses and load them offline also enables writing vignettes and other dynamic documents that can be distributed without access to a live server.
Authors:
httptest2_1.2.2.tar.gz
httptest2_1.2.2.zip(r-4.7)httptest2_1.2.2.zip(r-4.6)httptest2_1.2.2.zip(r-4.5)
httptest2_1.2.2.tgz(r-4.6-any)httptest2_1.2.2.tgz(r-4.5-any)
httptest2_1.2.2.tar.gz(r-4.7-any)httptest2_1.2.2.tar.gz(r-4.6-any)
httptest2_1.2.2.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
card.svg |card.png
httptest2/json (API)
NEWS
| # Install 'httptest2' in R: |
| install.packages('httptest2', repos = c('https://nealrichardson.r-universe.dev', 'https://cloud.r-project.org')) |
Bug tracker:https://github.com/nealrichardson/httptest2/issues
Pkgdown/docs site:https://enpiar.com
Last updated from:5e4a8d3b4d. Checks:9 OK. Indexed: yes.
| Target | Result | Time | Files | Syslog |
|---|---|---|---|---|
| linux-devel-x86_64 | OK | 137 | ||
| source / vignettes | OK | 177 | ||
| linux-release-x86_64 | OK | 137 | ||
| macos-release-arm64 | OK | 77 | ||
| macos-oldrel-arm64 | OK | 152 | ||
| windows-devel | OK | 96 | ||
| windows-release | OK | 106 | ||
| windows-oldrel | OK | 88 | ||
| wasm-release | OK | 107 |
Exports:.mockPathsblock_requestsbuild_mock_urlcapture_requestschange_stateend_vignetteexpect_DELETEexpect_GETexpect_no_requestexpect_PATCHexpect_POSTexpect_PUTexpect_request_headerfind_mock_fileget_current_redactorgsub_responseredact_cookiesredact_headerssave_responseset_redactorstart_capturingstart_vignettestop_capturingstop_mockinguse_httptest2use_mock_apiwith_mock_apiwith_mock_dirwith_tracewithin_body_textwithout_internet
Dependencies:askpassbriocallrclicrayoncurldescdiffobjdigestevaluatefsgluehttr2jsonlitelifecyclemagrittropensslpkgbuildpkgloadpraiseprocessxpsR6rappdirsrlangrprojrootsystestthatvctrswaldowithr
Frequently Asked Questions
Rendered fromfaq.Rmdusingknitr::rmarkdownon May 09 2026.Last update: 2023-07-06
Started: 2020-12-15
httptest: A Test Environment for HTTP Requests in R
Rendered fromhttptest2.Rmdusingknitr::rmarkdownon May 09 2026.Last update: 2025-06-27
Started: 2021-12-29
Redacting and Modifying Recorded Requests
Rendered fromredacting.Rmdusingknitr::rmarkdownon May 09 2026.Last update: 2025-06-27
Started: 2017-10-08
Writing Vignettes with APIs
Rendered fromvignettes.Rmdusingknitr::rmarkdownon May 09 2026.Last update: 2025-06-27
Started: 2018-01-12
Readme and manuals
Help Manual
| Help page | Topics |
|---|---|
| Set an alternate directory for mock API fixtures | .mockPaths |
| Record API responses as mock files | capture_requests start_capturing stop_capturing |
| Handle a change of server state | change_state |
| Test that an HTTP request is made with a header | expect_request_header |
| Expectations for mocked HTTP requests | expect_DELETE expect_GET expect_no_request expect_PATCH expect_POST expect_PUT expect_verb |
| Find and replace within a response object | gsub_response |
| Remove sensitive content from HTTP responses | redact redact_cookies redact_headers within_body_text |
| Set a response redactor | set_redactor |
| Set mocking/capturing state for a vignette | end_vignette start_vignette |
| Use 'httptest2' in your tests | use_httptest2 |
| Serve a mock API from files | stop_mocking use_mock_api with_mock_api |
| Use or create mock files depending on their existence | with_mock_dir |
| Make all HTTP requests raise an error | block_requests without_internet |
