Gavel is a JavaScript library designed for validating actual HTTP messages against expected HTTP messages. It provides a detailed comparison, indicating discrepancies in status codes, headers, and body content. The library supports JSON Schema validation (Draft 4, 6, and 7) for defining complex body expectations. The current stable version is 10.0.4, last released in December 2021. Its release cadence appears infrequent, with recent updates primarily focused on security patches for internal dependencies rather than new feature development. Gavel differentiates itself by offering granular validation results, pinpointing exact failures, including specific error messages and locations within JSON Schema mismatches, making it a valuable tool for API contract testing and robust HTTP interaction validation.
npm install gavelVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic HTTP transaction validation, including status code, headers, and JSON body against a schema.
Ensure your Node.js environment is at least v10.18.0. Update Node.js if necessary.
For Windows users, use the Node.js API directly or a WSL (Windows Subsystem for Linux) environment for CLI usage.
Regularly update `gavel` to the latest patch version to incorporate critical security fixes. Perform routine dependency audits.
Use ESM `import gavel from 'gavel';` instead of `const gavel = require('gavel');`.Adjust the `expected.statusCode` value to match the anticipated actual status code, or verify that the actual response is indeed incorrect.
Modify the `actual.body` to match the expected JSON Schema structure and data types, or refine the `expected.bodySchema` to accurately reflect valid inputs.
No dependency data recorded yet.