0.0.5 • Published 7 years ago

jest-json-schema-matchers v0.0.5

Weekly downloads
71
License
MIT
Repository
github
Last release
7 years ago

jest-json-schema-matchers

Install

npm install jest-json-schema-matchers

Example usage

// __tests__/data/data.json

{
  "base": {
    "referenced": {
      "name": "Referenced data schema"
    }
  }
}


// __tests__/schemas/base.json

{
  "type": "object",
  "required": ["base"],

  "properties": {
    "base": {
      "type": "object",
      "required": ["referenced"],

      "properties": {
        "referenced": {
          "$ref": "descriptions/referenced.json"
        }
      }
    }
  }
}

// __tests__/schemas/descriptions/referenced.json

{
  "type": "object",
  "required": ["name"],

  "properties": {
    "name": {
      "type": "string"
    }
  }
}

// __tests__/index.spec.js

const matchers = require('jest-json-schema-matchers');
expect.extend(matchers({
  schemaRoot: '__tests__/schemas/',
}));

describe('jest-json-schema-matchers', () => {
  it('matches json schema and resolves references', () => {
    const data = require('./data/data.json');

    expect(data).toMatchSchema('base.json');
  });
})
0.0.5

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago