| name | testing |
| description | Lingua's testing tools for transformation coverage and end-to-end SDK validation. |
Lingua Testing
Two complementary testing approaches for validating cross-provider transformations.
Overview
| Tool | Purpose | Uses API? | When to Use |
|---|
coverage-report | Field-level roundtrip coverage | No | Finding missing/changed fields |
lingua-capture + test:transforms | Real SDK validation | Capture only | Validating against real APIs |
Coverage Report (Rust)
Tests transformations roundtrip without calling APIs. Detects lost, added, or changed fields.
Quick Iteration (Compact Mode)
cargo run --bin coverage-report -- -f compact
cargo run --bin coverage-report -- -f compact -p anthropic,responses
cargo run --bin coverage-report -- -f compact -t "reasoning*"
Full Investigation (Markdown Mode)
cargo run --bin coverage-report
cargo run --bin coverage-report -- -p anthropic > .Codex/anthropic_bugs.md
Reading Compact Output
Stats: 669/1704 (39.3%) [512+157lim] 1035fail
[P1] L:usage.prompt_cache_tokens (123)
ant→ggl: cacheParam (response)...(+44)
L: = Lost fields, A: = Added, C: = Changed
(123) = affected test cases
- Abbreviations:
oai=ChatCompletions, ant=Anthropic, rsp=Responses, ggl=Google, bed=Bedrock
SDK Transforms Testing (TypeScript)
Validates against real provider SDKs with schema validation at every step.
Transformation Pairs
chat-completions ↔ anthropic
responses ↔ anthropic
Capture Responses
Calls real SDKs (requires API keys):
cd payloads
pnpm lingua-capture
pnpm lingua-capture --force
pnpm lingua-capture toolCall
Output: transforms/{source}_to_{target}/{caseName}.json
Run Tests
Uses captured responses (no API calls):
cd payloads
pnpm test:transforms
pnpm test:transforms:update
pnpm test:transforms:watch
What It Validates
- Request transform → validates output against target schema
- Load captured response → validates against target response schema
- Response transform back → validates against source schema
- Snapshots → detects unintended output changes
Known Incompatibilities
Some transformations are impossible. Document in transform_errors.json:
{
"responses_to_anthropic": {
"reasoningRequestTruncated": "max_tokens (100) < budget_tokens (1024 min)"
}
}
These tests pass silently.
Workflow
Adding a New Test Case
-
Add case to payloads/cases/:
newFeature: {
"chat-completions": { model: "...", messages: [...] },
anthropic: { model: "...", max_tokens: 1024, messages: [...] },
}
-
Check coverage:
cargo run --bin coverage-report -- -f compact -t newFeature
-
Capture SDK responses:
cd payloads && pnpm lingua-capture newFeature
-
Run transform tests:
pnpm test:transforms
Fixing a Transformation Bug
-
Investigate with full coverage report:
cargo run --bin coverage-report -- -p anthropic,responses > .Codex/fix_bugs.md
-
Iterate with compact mode:
cargo run --bin coverage-report -- -f compact -p anthropic,responses
-
Verify SDK compatibility:
cd payloads && pnpm test:transforms
-
If snapshots changed intentionally:
pnpm test:transforms:update