SKILL.md
SKILL.mdBrowse 2 files
854 tokens
3,354 bytes
Token encoding: o200k_base
Snapshot 9e9fdc4
1---2name: testing-skill3description: Record, rewrite, and debug VCR cassettes for HTTP recordings. Use when running tests with --record-mode, verifying cassette playback, or inspecting request/response bodies in YAML cassettes.4allowed-tools: Bash(uv run pytest *), Bash(uv run python .claude/skills/testing-skill/parse_cassette.py *), Bash(source .env && uv run pytest *), Bash(git diff *)5---6 7# Pytest VCR Workflow8 9Use this skill when recording or re-recording VCR cassettes for tests, or when debugging cassette contents.10 11## Prerequisites12 13- Verify `.env` exists: `test -f .env && echo 'ok' || echo 'missing'`14- Missing API keys will cause clear test errors at runtime15 16## Important flags17- `--record-mode=rewrite` : Record cassettes (works for both new and existing)18- `--lf` : Run only the last failed tests19- `-vv` : Verbose output20- `--tb=line` : Short traceback output21- `-k=""` : Run tests matching the given substring expression22 23## Recording Cassettes24 25### Step 1: Record cassettes26 27```bash28source .env && uv run pytest path/to/test.py::test_function_name -v --tb=line --record-mode=rewrite29```30 31Multiple tests can be specified:32```bash33source .env && uv run pytest path/to/test.py::test_one path/to/test.py::test_two -v --tb=line --record-mode=rewrite34```35 36### Step 2: Verify recordings37 38Run the same tests WITHOUT `--record-mode` to verify cassettes play back correctly:39```bash40source .env && uv run pytest path/to/test.py::test_function_name -vv --tb=line41```42 43### Step 3: Review snapshots44 45If tests use [`snapshot()`](https://github.com/15r10nk/inline-snapshot) assertions:46- The test run in Step 2 auto-fills snapshot content47- Review the generated snapshot files to ensure they match expected output48- You only review - don't manually write snapshot contents49- Snapshots capture what the test actually produced, additional to explicit assertions50 51## Parsing Cassettes52 53Parse VCR cassette YAML files to inspect request/response bodies without dealing with raw YAML.54 55### Usage56 57```bash58uv run python .claude/skills/testing-skill/parse_cassette.py <cassette_path> [--interaction N]59```60 61### Examples62 63```bash64# Parse all interactions in a cassette65uv run python .claude/skills/testing-skill/parse_cassette.py tests/models/cassettes/test_foo/test_bar.yaml66 67# Parse only interaction 1 (0-indexed)68uv run python .claude/skills/testing-skill/parse_cassette.py tests/models/cassettes/test_foo/test_bar.yaml --interaction 169```70 71### Output72 73For each interaction, shows:74- Request: method, URI, parsed body (truncated base64)75- Response: status code, parsed body (truncated base64)76 77Base64 strings longer than 100 chars are truncated for readability.78 79 80## Full Workflow Example81 82```bash83# 1. Record cassette84source .env && uv run pytest tests/models/test_openai.py::test_chat_completion -v --tb=line --record-mode=rewrite85 86# 2. Verify playback and fill snapshots87source .env && uv run pytest tests/models/test_openai.py::test_chat_completion -vv --tb=line88 89# 3. Review test code diffs (excludes cassettes)90git diff tests/ -- ':!**/cassettes/**'91 92# 4. List new/changed cassettes (name only - use parse_cassette.py to inspect)93git diff --name-only tests/ -- '**/cassettes/**'94 95# 5. Inspect cassette contents if needed96uv run python .claude/skills/testing-skill/parse_cassette.py tests/models/cassettes/test_openai/test_chat_completion.yaml97```98 Discovery context
Discovered by repository scan. No exact path reference found in the snapshot’s root AGENTS.md.