npm install jest-joi-schema --save
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,
);