Ghost/ghost/core/test/utils/assertions.js
Naz 112ab23968
Removed direct use of @tryghost/jest-snapshot
refs https://github.com/TryGhost/Toolbox/issues/499
refs 6bcc47a0ad

- Using module directly caused issues with snapshots manager instance initialization (mocha hooks did not apply to a correct instance)
- See refed commit for more
2023-01-17 12:50:49 +08:00

23 lines
767 B
JavaScript

const should = require('should');
const errorProps = ['message', 'errorType'];
const {matchSnapshotAssertion} = require('@tryghost/express-test').snapshot;
should.Assertion.add('JSONErrorObject', function () {
this.params = {operator: 'to be a valid JSON Error Object'};
this.obj.should.be.an.Object();
this.obj.should.have.properties(errorProps);
});
should.Assertion.add('JSONErrorResponse', function () {
this.params = {operator: 'to be a valid JSON Error Response'};
this.obj.should.have.property('errors').which.is.an.Array();
this.obj.errors.length.should.be.above(0);
this.obj.errors.forEach(function (err) {
err.should.be.a.JSONErrorObject();
});
});
should.Assertion.add('matchSnapshot', matchSnapshotAssertion);