Postman:如何在Postman自动化中检查字段是否返回null [英] Postman: How to check whether the field is returning null in the Postman automation

查看:1332
本文介绍了Postman:如何在Postman自动化中检查字段是否返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过!== null,但即使字段返回0或,它也会返回PASS。

I have tried with "!== null", but it is returning PASS even when the field is returning 0 or "".

推荐答案

如果要检查列表中返回的第一项的Id,可以使用 not.equal(null)

If you are checking the Id of the first item returned in a list, you could use not.equal(null):

pm.expect(pm.response.json().value[0].Id).not.equal(null);

请注意,等于这个词是完全拼写的,尽管缩短的eql确实有效。

Note that the word "equal" is fully spelled out, although the shortened "eql" does work.

这篇关于Postman:如何在Postman自动化中检查字段是否返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆