1.0.0 • Published 5 years ago

jest-joi-schema v1.0.0

Weekly downloads
32
License
ISC
Repository
github
Last release
5 years ago

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,
);