Skip to content

API mocking for package tests #147

@nickdickinson

Description

@nickdickinson

API mocking would be useful for the following:

  • Reduce the number of API calls during testing of non-mutating interactions and enable periodic update of mocking as needed
  • Run vignettes using mocking to avoid authentication and the need to keep resources online making them easier to maintain as the R package changes
  • Enabling the tests to run in CRAN so that the package can be submitted to CRAN. Alternatively we could disable testing in CRAN for tests that use the API/internet.
  • Potentially use also in the Roxygen examples

The space has grown considerably with the following useful packages:

  • vcr (httr and httr2 supported
  • httptest (for httr) or httptest2 (for httr2)
  • webmockr

This is a good introduction to API mocking in R: https://books.ropensci.org/http-testing/index.html

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions