tests/testthat/setup.R

# Setup file for httptest2 mocking
# httptest2 is optional - only loaded if available

if (requireNamespace("httptest2", quietly = TRUE)) {
  library(httptest2)
  
  # Use recorded responses during testing
  # To record new fixtures, run tests with:
  #   with_mock_api(test_that(...)
  
  # Set redactor for all tests (to hide API keys in recordings)
  set_redactor(function(response) {
    # Redact API keys from recorded responses
    response <- gsub_response(response, "sk-[a-zA-Z0-9]+", "sk-REDACTED")
    response <- gsub_response(response, "sk-ant-[a-zA-Z0-9-]+", "sk-ant-REDACTED")
    response
  })
}

Try the aisdk package in your browser

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

aisdk documentation built on May 29, 2026, 9:07 a.m.