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.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'))

Peer review:

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

On CRAN:

httpmocktesting

31 exports 26 stars 9.12 score 37 dependencies 1 dependents 72 scripts 2.7k downloads

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

TargetResultDate
Doc / VignettesOKSep 14 2024
R-4.5-winOKSep 14 2024
R-4.5-linuxOKSep 14 2024
R-4.4-winOKSep 14 2024
R-4.4-macOKSep 14 2024
R-4.3-winOKSep 14 2024
R-4.3-macOKSep 14 2024

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

Frequently Asked Questions

Rendered fromfaq.Rmdusingknitr::rmarkdownon Sep 14 2024.

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

httptest: A Test Environment for HTTP Requests in R

Rendered fromhttptest2.Rmdusingknitr::rmarkdownon Sep 14 2024.

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

Redacting and Modifying Recorded Requests

Rendered fromredacting.Rmdusingknitr::rmarkdownon Sep 14 2024.

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

Writing Vignettes with APIs

Rendered fromvignettes.Rmdusingknitr::rmarkdownon Sep 14 2024.

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