Contexts

with_mock_api with_mock_API

Serve a mock API from files

use_mock_api

Turn on API mocking

without_internet

Make all HTTP requests raise an error

block_requests

Block HTTP requests

with_fake_http with_fake_HTTP

Make all HTTP requests return a fake response

stop_mocking

Turn off request mocking

Expectations

expect_GET expect_POST expect_PATCH expect_PUT expect_DELETE expect_no_request

Expectations for mocked HTTP requests

expect_header

Test that an HTTP request is made with a header

expect_json_equivalent

Test that objects would generate equivalent JSON

Recording and redacting responses

capture_requests start_capturing stop_capturing

Record API responses as mock files

redact_cookies redact_headers redact_http_auth redact_oauth within_body_text redact_auth

Remove sensitive content from HTTP responses

gsub_response gsub_request

Find and replace within a 'response' or 'request'

set_redactor

Set a response redactor

Loading mock (recorded) fixtures

.mockPaths

Set an alternate directory for mock API fixtures

set_requester

Set a request preprocessor

build_mock_url buildMockURL

Convert a request to a mock file path

fake_response fakeResponse

Return something that looks like an httr 'response'

Vignettes

start_vignette end_vignette

Set mocking/capturing state for a vignette

change_state

Handle a change of server state

Other testing tools

public

Test that functions are exported

skip_if_disconnected

Skip tests that need an internet connection if you don't have one