A Jest matcher for validating objects against JSON Schema (draft-04, draft-06, draft-07, 2019-09, 2020-12 via Ajv). Version 6.1.0 supports Node ^12.13.0 || ^14.15.0 || >=15.0.0, with releases every few months. Provides `toMatchSchema` matcher and `matchersWithOptions` for advanced Ajv configuration (custom formats, keywords, Ajv class). Uses Ajv under the hood. Simpler than writing custom matchers, integrates seamlessly into Jest.
npm install jest-json-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic setup with import and use of toMatchSchema matcher to validate an object against a JSON schema.
Ensure schema has type/properties or $ref; use validators like Ajv standalone if unsure.
Use matchersWithOptions({ allErrors: false })Use AjvClass option to specify draft-04/06/2019-09/2020-12.
Run expect.extend(matchers) after import. Ensure import is correct: import { matchers } from 'jest-json-schema';npm install ajv --save-dev and import Ajv from 'ajv'.
Use matchersWithOptions with addSchema to include all referenced schemas.