Postman测试-TV4.Validateresult TypeError:无法阅读属性' $ ref'不确定的

发布于 2025-01-31 02:13:47 字数 363 浏览 10 评论 0原文

我正在使用邮递员,我添加了一个测试来验证响应的模式。 架构和响应模式按预期返回,但是在以下代码中的某个地方会遇到错误“ 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 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;
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慢慢从新开始 2025-02-07 02:13:47

我切换到了这个小魔术脚本

 pm.test(tag + ".SCHEMA response matches required schema", function() {
    var valid = tv4.validate(jsonRes, schema, false, true);
    pm.expect(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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文