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;
});
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.