Package: httptest2 1.2.2.9000

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:Neal Richardson [aut, cre], Jonathan Keane [ctb], Maëlle Salmon [ctb]

httptest2_1.2.2.9000.tar.gz
httptest2_1.2.2.9000.zip(r-4.7)httptest2_1.2.2.9000.zip(r-4.6)httptest2_1.2.2.9000.zip(r-4.5)
httptest2_1.2.2.9000.tgz(r-4.6-any)httptest2_1.2.2.9000.tgz(r-4.5-any)
httptest2_1.2.2.9000.tar.gz(r-4.7-any)httptest2_1.2.2.9000.tar.gz(r-4.6-any)
httptest2_1.2.2.9000.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
httptest2/json (API)

# 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

On CRAN:

Conda:

httpmocktesting

10.44 score 36 stars 1 packages 201 scripts 8.8k downloads 31 exports 32 dependencies

Last updated from:37efe13ff4. Checks:7 NOTE, 2 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64NOTE138
source / vignettesOK209
linux-release-x86_64NOTE129
macos-release-arm64NOTE121
macos-oldrel-arm64NOTE91
windows-develNOTE95
windows-releaseNOTE81
windows-oldrelNOTE86
wasm-releaseOK141

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:askpassbriocallrclicrayoncurldescdiffobjdigestevaluatefsgluehttr2jsonlitelifecyclemagrittropensslotelpkgbuildpkgloadpraiseprocessxpsR6rappdirsrlangrprojrootsystestthatvctrswaldowithr

httptest: A Test Environment for HTTP Requests in R
Getting started | Basic tests from a live server | Going deeper

Last update: 2025-06-27
Started: 2021-12-29

Redacting and Modifying Recorded Requests
Default: redact standard auth methods | Writing custom redacting functions | Setting a package-level redactor | URL shortening

Last update: 2025-06-27
Started: 2017-10-08

Writing Vignettes with APIs
The basics: start_vignette() | Handling server state changes | Advanced topics

Last update: 2025-06-27
Started: 2018-01-12

Frequently Asked Questions
Where are my mocks recorded? | How do I fix "non-portable file paths"? | Why are mocks stored as text files?

Last update: 2023-07-06
Started: 2020-12-15

Readme and manuals

Help Manual

Help pageTopics
Set an alternate directory for mock API fixtures.mockPaths
Record API responses as mock filescapture_requests start_capturing stop_capturing
Handle a change of server statechange_state
Test that an HTTP request is made with a headerexpect_request_header
Expectations for mocked HTTP requestsexpect_DELETE expect_GET expect_no_request expect_PATCH expect_POST expect_PUT expect_verb
Find and replace within a response objectgsub_response
Remove sensitive content from HTTP responsesredact redact_cookies redact_headers within_body_text
Set a response redactorset_redactor
Set mocking/capturing state for a vignetteend_vignette start_vignette
Use 'httptest2' in your testsuse_httptest2
Serve a mock API from filesstop_mocking use_mock_api with_mock_api
Use or create mock files depending on their existencewith_mock_dir
Make all HTTP requests raise an errorblock_requests without_internet