mock_with_dir not functioning properly?

I'm looking at this documentation and following the steps, but not getting the expected results:
Chapter 7 Use httptest | HTTP testing in R. Specifically the "dir" directory is not written, files are not captured, and when I attempt to re-run the tests offline they fail.

  1. Using R 4.4.2 (slightly out of date, but I without admin rights nothing I can do about that. Still shouldn't be a problem).
  2. Installed and loaded httptest
  3. ran > httptest::use_httptest(), which generated the setup file containing "library(httptest)"

wrote the following test, which passes when run (locally, while on-line):

httptest::with_mock_dir("get_data_packages_test_dir", {
  test_that("get_data_packages creates the expected directory structure", {
    
    local <- withr::local_tempdir()
    x <- NPSutils::get_data_packages(2295255,
                           path = local,
                           force = FALSE,
                           dev = FALSE)
    expect_true(dir.exists(file.path(local,"data", "2295255")))
    setwd(here::here())
  })
})

However if I disconnect from the internet and attempt to use the capture files when re-running the test, it fails. A "dir" directory is not created under "tests/testthat" and there are no files in it. Instead, the files are downloaded to the temp directory.

Some notes:

  1. if I omit the "setwd(here::here()) line, my working directory gets changed to a temp directory.

  2. if I omit the "local <- withr::local_tempdir()" line (and the path = local and file.path(local, ... :

httptest::with_mock_dir("get_data_packages_test_dir", {
  test_that("get_data_packages creates the expected directory structure", {
    
    #local <- withr::local_tempdir()
    x <- NPSutils::get_data_packages(2295255,
                           force = FALSE,
                           dev = FALSE)
    expect_true(dir.exists(file.path("data", "2295255")))
    #setwd(here::here())
  })
})

then the "dir" directory is not created; instead a directory in the project's home directory is created (not the "dir" directory but the "data" directory that the function writes). The "dir" directory is also not created under tests/testthat

Why isn't the "dir" directory being created under tests/testthat?