Skip to contents

Getting started

use_httptest2()
Use 'httptest2' in your tests

Test contexts

with_mock_api() use_mock_api() stop_mocking()
Serve a mock API from files
with_mock_dir()
Use or create mock files depending on their existence
without_internet() block_requests()
Make all HTTP requests raise an error
.mockPaths()
Set an alternate directory for mock API fixtures

Recording and redacting responses

capture_requests() start_capturing() stop_capturing()
Record API responses as mock files
redact_cookies() redact_headers() within_body_text()
Remove sensitive content from HTTP responses
gsub_response()
Find and replace within a response object
set_redactor()
Set a response redactor

Expectations

expect_GET() expect_POST() expect_PATCH() expect_PUT() expect_DELETE() expect_no_request()
Expectations for mocked HTTP requests
expect_request_header()
Test that an HTTP request is made with a header

Vignettes

start_vignette() end_vignette()
Set mocking/capturing state for a vignette
change_state()
Handle a change of server state