Skip to content

Enable offline cassette replay for VCR-backed tests#161

Merged
aaronwolen merged 8 commits intomasterfrom
finish-testthat-v3-migration
Feb 21, 2026
Merged

Enable offline cassette replay for VCR-backed tests#161
aaronwolen merged 8 commits intomasterfrom
finish-testthat-v3-migration

Conversation

@aaronwolen
Copy link
Member

@aaronwolen aaronwolen commented Feb 20, 2026

Summary

  • Remove skip_if_no_pat() from all VCR-backed tests so they can run offline using recorded cassettes
  • Move test fixture setup (project/component creation) out of if (has_pat()) guards and into vcr::use_cassette() blocks at file-level, enabling cassette replay without credentials
  • Create cassettes for osf_ls and osf_tbl so these test files no longer require a live server
  • Rename skip_on_production_server() to skip_if_not_test_server() for clarity and add it alongside skip_if_no_pat() in downloading tests, which are the only tests that still require live server access
  • Remove remaining context() calls, replacing them with section comment headers
  • Add tests/testthat/README.md documenting the three testing modes (offline, test server, production server)

NOTE: Only test-downloading.R requires both OSF_PAT and OSF_SERVER=test, since downloads depend on pre-existing assets on test.osf.io and can't be meaningfully recorded as cassettes.

Rename skip_on_production_server() to skip_if_not_test_server() for
tests that depend on pre-existing assets on test.osf.io (test-osf_ls),
and switch to skip_if_no_pat() for tests that require authentication
(test-osf_tbl).
Add skip_if_not_test_server() for tests that depend on pre-existing
assets on test.osf.io. Apply it to test-downloading.R (alongside
skip_if_no_pat) and the test-osf_tbl "can't combine" test that uses a
hardcoded test server GUID.

Add a README documenting the three testing modes (offline with
cassettes, live test server, live production server) and the skip
helpers.
Wrap API calls in vcr::use_cassette() so these tests replay recorded
responses instead of requiring a live connection to test.osf.io. This
brings them in line with the rest of the test suite.
Remove `if (has_pat())` guards from setup blocks and `skip_if_no_pat()`
from individual tests so VCR cassettes replay without credentials.
Teardown blocks that conditionally clean up live resources are kept
unchanged. Also remove the unnecessary skip from the pure `id_type()`
test in test-identifiers.R.

Offline results improve from ~30 pass / ~74 skip to 150 pass / 9 skip,
with all remaining skips in test-downloading.R (which requires live
file access).
@aaronwolen aaronwolen changed the title Finish updating tests Enable offline cassette replay for VCR-backed tests Feb 21, 2026
@aaronwolen aaronwolen marked this pull request as ready for review February 21, 2026 18:32
@aaronwolen aaronwolen merged commit 991dfcf into master Feb 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant