A framework-agnostic fault simulation library for API testing in TypeScript. Inspired by mutation testing, MetaTester automatically injects faults into API responses to test the robustness of your test suite.
- Zero Code Changes - Just import and activate via environment variable
- Framework Agnostic - Works with Jest, Mocha, and other test frameworks
- HTTP Client Support - Axios, Fetch, and extensible to others
- Comprehensive Reports - JSON reports with detailed fault simulation results
- Plugin Architecture - Easy to extend with custom fault types and adapters
npm install @your-org/metatester-ts --save-dev
// In your test setup file or at the top of your test files
import '@your-org/metatester-ts';
# Run normal tests
npm test
# Run tests with fault simulation
METATESTER_ACTIVE=true npm test
Create a config.yml
file in your project root:
faults:
null_field:
enabled: true
missing_field:
enabled: true
empty_string:
enabled: true
empty_list:
enabled: true
invalid_value:
enabled: true
endpoints:
exclude:
- '*/demo*'
tests:
exclude:
- '*demo*'
report:
format: json
output_path: "./reports/simulator-report.json"
- Test Interception: MetaTester intercepts your test functions using framework adapters
- HTTP Capture: Original API responses are captured during the first test run
- Fault Injection: Tests are re-run with mutated responses (null fields, missing data, etc.)
- Result Analysis: Each fault is classified as caught (test failed) or missed (test passed)
- Report Generation: Comprehensive JSON report with statistics and details
{
"metadata": {
"generated_at": "2025-08-30T20:00:13.550Z",
"total_endpoints": 2,
"total_fields": 24,
"total_faults": 120,
"total_tests": 315,
"caught_faults": 38,
"missed_faults": 277
}
}
MIT