简体   繁体   English

邮递员测试 - tv4.validateResult TypeError:无法读取未定义的属性“$ref”

[英]Postman Test - tv4.validateResult TypeError: Cannot read property '$ref' of undefined

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".架构和响应架构按预期返回,但在以下代码的某处我收到错误“tv4.validateResult TypeError:无法读取未定义的属性'$ref'”。

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不知道为什么,希望有人补充一些澄清

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM