[英]How to join 2 different assertions in cypress?
伙计们。 您知道如何连接 2 个不同的断言吗?
assert.isNotNull(res.body, "is not null");
assert.isNotNull(res.body.createdAt, "is not null");
参考: https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
将你的断言包裹在Promise.all
Promise.all([
assert.isNotNull(res.body, "is not null"),
assert.isNotNull(res.body.createdAt, "is not null")
])
您传递了一系列断言。 两者都必须通过才能通过断言。
您可以将expect
chai 断言与&&
一起使用,例如:
expect(res.body).to.not.be.null && expect(res.body.createdAt).to.not.be.null
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.