Reputation: 31
I am using postman, i have added a test to validate the schema of the response. The schema and response schema return as expected, but somewhere in the following code i get the error "tv4.validateResult TypeError: Cannot read property '$ref' of undefined".
pm.test(tag + ".SCHEMA response matches required schema", function() {
var result = tv4.validateResult(jsonRes, schema.response);
if (!result.valid) {console.log(result);}
pm.expect(result.valid).to.be.true;
});
Upvotes: 1
Views: 259
Reputation: 31
I switched to this little magic script
pm.test(tag + ".SCHEMA response matches required schema", function() {
var valid = tv4.validate(jsonRes, schema, false, true);
pm.expect(valid).to.be.true;
});
and it worked. Not sure why, hoping for someone to add some clarification
Upvotes: 1