tests/testthat/test-last_stub.R

test_that("last_stub works when no stubs found", {
  stub_registry_clear()

  expect_null(last_stub())
})

test_that("last_stub works when stubs are found", {
  stub_registry_clear()

  stub_request("head", "https://nytimes.com")

  expect_s3_class(last_stub(), "StubbedRequest")
})

Try the webmockr package in your browser

Any scripts or data that you put into this service are public.

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