webmockr-package: webmockr: Stubbing and Setting Expectations on 'HTTP'...

webmockr-packageR Documentation

webmockr: Stubbing and Setting Expectations on 'HTTP' Requests

Description

Stubbing and setting expectations on 'HTTP' requests. Includes tools for stubbing 'HTTP' requests, including expected request conditions and response conditions. Match on 'HTTP' method, query parameters, request body, headers and more. Can be used for unit tests or outside of a testing context.

Features

  • Stubbing HTTP requests at low http client lib level

  • Setting and verifying expectations on HTTP requests

  • Matching requests based on method, URI, headers and body

  • Supports multiple HTTP libraries, including crul, httr, and httr2

  • Integration with HTTP test caching library vcr

  • Supports async http request mocking with crul only

Author(s)

Maintainer: Scott Chamberlain myrmecocystus+r@gmail.com (ORCID)

Other contributors:

  • Aaron Wolen (ORCID) [contributor]

  • rOpenSci (019jywm96) [funder]

See Also

Useful links:

Examples

library(webmockr)
stub_request("get", "https://httpbin.org/get")
stub_request("post", "https://httpbin.org/post")
stub_registry()


webmockr documentation built on April 4, 2025, 12:08 a.m.