Chakram assertion for checking responses using Joi schema.
npm install --save-dev chakram-joi
chakram.addMethod('joi', require('chakram-joi'));
const schema = joi.object().keys({
name: joi.string()
});
expect(response).to.joi(schema);
Joi has several options for validation and it's possible to use them as shown bellow:
expect(response).to.joi(schema, { abortEarly: false });
Default options:
abortEarly: true # stops validation on the first error
presence: 'required' # declared items must be found
allowUnknown: true # unknown object keys are ignored
MIT