npm.io
1.0.0 • Published 7 years ago

jest-joi-schema

Licence
ISC
Version
1.0.0
Deps
0
Size
2 kB
Vulns
0
Weekly
0

jest-joi-schema

Joi schema matcher for Jest.

Install via npm

npm install jest-joi-schema --save

Usage

In any test file:

import { matchers } from 'jest-joi-schema';
expect.extend(matchers);

or add it directly in setupTestFrameworkScriptFile.

const joi = require('joi');

const userSchema = joi.object({
  firstName: joi.string().required(),
  lastName: joi.string().required(),
  email: joi.string().email(),
});

const options = { allowUnknown: true };

expect(values).toMatchSchema(
  userSchema,
  options,
);

Keywords