Just published version 1.5.0 of the webfakes package.
webfakes 1.5.0 fixes some bugs and has some quality of life improvements. See the release notes for the full list of changes.
webfakes love
I really like the webfakes package. It makes testing code that does HTTP so much easier. I can be confident that the code works as intended, and it keeps working perfectly as it is refactored and extended.
We use it in many packages that use HTTP: httr2, pins, pkgcache, pkgdepends, rhub and others.
Sometimes you don’t need to write a custom webfakes app to write your
tests, and e.g. the built-in webfakes::httpbin_app() suffices.
But I especially like the use cases where a custom fake app makes
testing easy and thorough.
Example webfakes apps
For example pkgcache has a CRAN app that pretends to be a CRAN repository.
It takes a package metadata file (PACKAGES file) as the input, and then
serves proper R package files for the packages defined in this file.
This makes it easy to reliably test edge cases in CRAN-like repositories.
The apps I wrote recently help testing single sign-on authentication of Posit Package Manager.
The first app correctly authenticates against a test service at https://auth0.com/, which provides a free developer account. This is very useful for interactive testing.
The second app runs completely locally and only fakes the authentication, so it is great for use in a test suite.