DEPRECATED. Use https://www.npmjs.com/package/jest-json-schema instead
This plugin was inspired by chai-json-schema and chai-json-schema-ajv.
npm install --save-dev jasmine-ajv
For any references, please follow
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);
});
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!
TBD, if you have a PR, you're welcome!