Package: httptest 4.2.3

httptest: A Test Environment for HTTP Requests

Testing and documenting code that communicates with remote servers can be painful. Dealing with authentication, server state, and other complications can make testing seem too costly to bother with. But it doesn't need to be that hard. This package enables one to test all of the logic on the R sides of the API in your package without requiring access to the remote service. Importantly, it provides three contexts that mock the network connection in different ways, as well as testing functions to assert that HTTP requests were---or were not---made. It also allows one to safely record real API responses to use as test fixtures. The ability to save responses and load them offline also enables one to write 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]

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

# Install 'httptest' in R:
install.packages('httptest', repos = c('https://nealrichardson.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/nealrichardson/httptest/issues

Pkgdown/docs site:https://enpiar.com

On CRAN:

Conda:

httpmocktest-framework

9.90 score 83 stars 421 scripts 5.2k downloads 40 exports 31 dependencies

Last updated from:97b186987c. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK130
source / vignettesOK184
linux-release-x86_64OK134
macos-release-arm64OK92
macos-oldrel-arm64OK96
windows-develOK87
windows-releaseOK95
windows-oldrelOK134
wasm-releaseOK105

Exports:.mockPathsblock_requestsbuild_mock_urlcapture_requestschange_stateend_vignetteexpect_DELETEexpect_GETexpect_headerexpect_json_equivalentexpect_no_requestexpect_PATCHexpect_POSTexpect_PUTfake_responsefind_mock_fileget_current_redactorget_current_requestergsub_requestgsub_responsepublicredact_authredact_cookiesredact_headerssave_responseset_redactorset_requesterskip_if_disconnectedstart_capturingstart_vignettestop_capturingstop_mockinguse_httptestuse_mock_apiwith_fake_httpwith_mock_apiwith_mock_dirwith_tracewithin_body_textwithout_internet

Dependencies:askpassbriocallrclicrayoncurldescdiffobjdigestevaluatefsgluehttrjsonlitelifecyclemagrittrmimeopensslotelpkgbuildpkgloadpraiseprocessxpsR6rlangrprojrootsystestthatwaldowithr

Frequently Asked Questions
Where are my mocks recorded? | How do I fix "non-portable file paths"? | How do I switch between mocking and real requests?

Last update: 2025-11-16
Started: 2020-12-15

httptest: A Test Environment for HTTP Requests in R
The with_mock_api context | Example | Recording mocks with capture_requests | Automatically recording/playing back: the with_mock_dir() context | Mocks are text files | Testing that requests aren't made | Assert the shape of request payloads | Just test it

Last update: 2025-11-16
Started: 2017-06-01

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

Last update: 2025-11-16
Started: 2017-10-08

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

Last update: 2025-11-16
Started: 2018-01-12