maxmalov / jasmine-ajv

[DEPRECATED] Jasmine JSON schema validator with ajv help. Use https://github.com/americanexpress/jest-json-schema instead

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jasmine-ajv

DEPRECATED. Use https://www.npmjs.com/package/jest-json-schema instead

Build Status

This plugin was inspired by chai-json-schema and chai-json-schema-ajv.

Installation

npm install --save-dev jasmine-ajv

JSON Schema and Ajv

For any references, please follow

Setup and usage

For Jasmine, you'll need to call install function in any place due to the way jasmine's plugin system works, ex in beforeEach:

const installJsonSchemaMatcher = require('jasmine-ajv');

beforeEach(() => installJsonSchemaMatcher(jasmine));

it('should has toBeJsonSchema matcher', () => {
  expect(pojo).toBeJsonSchema(mySchema);
});

And you can use it even with jest

You need specify setup test file, if you haven't done so. After that add the following code to your setup file:

// setup file

const installJsonSchemaMatcher = require('jasmine-ajv');

installJsonSchemaMatcher(jasmine);

// and later in tests

test('how awesome it is', () => {
  expect(pojo).toBeJsonSchema(mySchema);
});

and you're ready to go!

Browser support

TBD, if you have a PR, you're welcome!

About

[DEPRECATED] Jasmine JSON schema validator with ajv help. Use https://github.com/americanexpress/jest-json-schema instead

License:MIT License


Languages

Language:JavaScript 100.0%