Skip to content

SteffenHummel/jest-json-schema-matcher

Repository files navigation

jest-json-schema-matcher

A very simple JSON Schema matcher for jest

Prerequisites

jest must be installed

Getting Started

installing via yarn

$ yarn add --dev jest-json-schema-matcher

or npm

$ npm install --save-dev jest-json-schema-matcher

Usage

import { jsonSchemaMatcher } from 'jest-json-schema-matcher'

expect.extend(jsonSchemaMatcher)

after this you can use it like

test('jsonSchemaMatcher matches schema', () => {
  const schema = {
    properties: {
      testProp: {
        type: 'integer',
      },
    },
    required: ['testProp'],
  }
  expect({ testProp: 1 }).toMatchSchema(schema)
})

Built With

Versioning

We use SemVer for versioning. For the versions available, see the version on this repository.

License

This project is licensed under the MIT License - see the LICENSE.md file for details