What Are Snapshots?
Breakdance uses the term “snapshot” to describe captured HTTP traffic that can be replayed during testing:Request Snapshots
.http files containing real HTTP requests you want to replay.Capture requests from browser DevTools, API documentation, or your own exploration. Define them once, run them everywhere.Response Snapshots
Response files containing real HTTP responses from APIs.Capture responses once from a real API, then replay them instantly without network calls.
Why Snapshots Beat Mocks
| Aspect | Traditional Mocks | Snapshots |
|---|---|---|
| Source of truth | Developer imagination | Real API behavior |
| Maintenance | Manual updates required | Re-capture when API changes |
| Accuracy | Prone to drift | Always reflects reality |
| Edge cases | Often forgotten | Naturally captured |
| Test confidence | ”Works with mocks" | "Works with real data” |
| Debugging | Artificial scenarios | Real-world scenarios |
The Snapshot Workflow
1
Capture
Record real HTTP traffic from the actual API. This happens once per endpoint or when the API changes.
- For requests: Copy from browser DevTools, API docs, or write
.httpfiles - For responses: Run your code against the real API with capture enabled
2
Store
Check snapshot files into source control alongside your tests. They become part of your test fixtures.
3
Replay
Tests read from snapshot files instead of making network calls. Fast, deterministic, and offline-capable.
4
Refresh
When APIs change, re-capture snapshots. Your tests immediately reveal any breaking changes.
When to Use Each Type
Request Snapshots (.http files)
Use request snapshots when you want to:
- Document API contracts in a readable format
- Share request examples with your team
- Test multiple variations of the same endpoint
- Chain requests together (login → get profile → update settings)
- Use environment-specific variables (dev/staging/prod URLs)
users.http
Response Snapshots
Use response snapshots when you want to:- Test against third-party APIs without hitting rate limits
- Run tests offline or in CI environments without API access
- Ensure deterministic test data (same response every time)
- Test error handling with captured error responses
- Avoid polluting real accounts with test data
Combining Both Approaches
The real power comes from combining request and response snapshots:- Readable requests in
.httpformat with variables and chaining - Real responses captured from actual API calls
- Fast execution with no network overhead
- Deterministic results for reliable CI/CD
Getting Started
Request Snapshots
Learn how to write and execute
.http files as unit testsResponse Snapshots
Learn how to capture and replay HTTP responses
Related Packages
| Package | Purpose |
|---|---|
Breakdance.DotHttp | Request snapshots via .http file parsing |
Breakdance.Assemblies | Response snapshot handlers |