From Betamax to VCR: harden your API integration testing
summary
Mocking hand‑written JSON fixtures causes silent false positives when the external API quietly changes; the practical fix shown is PHP-VCR which records real HTTP traffic (cURL/stream/SOAP) into cassette files (YAML/JSON/XML) and replays it in record/playback modes. An integration is built as a Pest trait that records integration tests once, speeds CI and enables offline dev — it works in practice but costs include credential handling, cassette naming, staging access and maintenance of an OSS recorder.
AI-written summary · about
chapters (21)
- 0:00Introduction
- 0:55About me
- 2:33Outline
- 3:55Betamax vs VCR
- 5:11The most practical solution
- 7:38People do this
- 11:37My problem
- 13:58How does VCR work
- 15:02How does VCR look
- 18:53Using VCR
- 19:36VCR examples
- 21:05Pros and cons
- 22:13Documentation
- 24:43External API
- 25:59Example
- 28:07Thoughts
- 29:07Staging environments
- 30:38Naming APIs
- 31:49Open Source
- 33:50Conclusion
- 36:06Questions
related talks
27mEffectively Testing Services
29m“Save $$ Testing Code the Playback-Based Way”
46mRecord-Replay API Test Cases & Data Mocks without writing code
24mRequre: Simplify your Integration&E2E tests
30mUnit Testing with Requests
45mTest Automation Requirements Through Recordings
20mIntegration Testing with Cypress
26mTesting HTTP APIs with Ruby
