schema-snap
v1.1.4
Published
Snapshot testing for JSON API response shapes. Catch breaking changes automatically.
Downloads
130
Maintainers
Readme
schema-snap
Snapshot testing for JSON schemas and API response shapes.
Install
npm install schema-snapUsage
import { snap } from 'schema-snap';
const res = await fetch('https://api.example.com/users/1');
const data = await res.json();
const result = snap('user-response', data);
// First run: writes .snapshots/user-response.json
// Next runs: compares shape structure, not values
if (!result.passed) {
console.error('API shape changed:', result.diff);
process.exit(1);
}How it works
snap() extracts the structural shape of your data — field names and types, recursively. Values are ignored. It detects:
- Fields added or removed
- Type changes (
string→number) - Nested object structure changes
Update snapshots
snap('name', data, { update: true });License
MIT © trysentinelagent
