Package: httptest2 1.1.0.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.1.0.9000.tar.gz
httptest2_1.1.0.9000.zip(r-4.5)httptest2_1.1.0.9000.zip(r-4.4)httptest2_1.1.0.9000.zip(r-4.3)
httptest2_1.1.0.9000.tgz(r-4.5-any)httptest2_1.1.0.9000.tgz(r-4.4-any)httptest2_1.1.0.9000.tgz(r-4.3-any)
httptest2_1.1.0.9000.tar.gz(r-4.5-noble)httptest2_1.1.0.9000.tar.gz(r-4.4-noble)
httptest2_1.1.0.9000.tgz(r-4.4-emscripten)httptest2_1.1.0.9000.tgz(r-4.3-emscripten)
httptest2.pdf |httptest2.html
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 site:https://enpiar.com

On CRAN:

Conda:

httpmocktesting

9.29 score 32 stars 1 packages 95 scripts 3.3k downloads 31 exports 31 dependencies

Last updated 8 months agofrom:5856ed57a5. Checks:8 OK. Indexed: yes.

TargetResultLatest binary
Doc / VignettesOKFeb 11 2025
R-4.5-winOKFeb 11 2025
R-4.5-macOKFeb 11 2025
R-4.5-linuxOKFeb 11 2025
R-4.4-winOKFeb 11 2025
R-4.4-macOKFeb 11 2025
R-4.3-winOKFeb 11 2025
R-4.3-macOKFeb 11 2025

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 Feb 11 2025.

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

httptest: A Test Environment for HTTP Requests in R

Rendered fromhttptest2.Rmdusingknitr::rmarkdownon Feb 11 2025.

Last update: 2022-01-02
Started: 2021-12-29

Redacting and Modifying Recorded Requests

Rendered fromredacting.Rmdusingknitr::rmarkdownon Feb 11 2025.

Last update: 2021-12-29
Started: 2017-10-08

Writing Vignettes with APIs

Rendered fromvignettes.Rmdusingknitr::rmarkdownon Feb 11 2025.

Last update: 2021-12-30
Started: 2018-01-12

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