我试图对请求正文进行断言,以确保正确的新测试卡作为订单的一部分通过。
it("User clicks confirm & pay button to complete order", () => {
cy.intercept("/api/checkout/payandcommit").as("placeOrder");
cy.placeOrderAndPay();
cy.wait("@placeOrder")
.its("response.statusCode")
.should("eq", 200)
.its("request.body")
.should("include", "cardNumber", 370000000000002);
});
Run Code Online (Sandbox Code Playgroud)
一切都很好,直到验证状态代码然后它就中断了。
这是抛出的错误:
Timed out retrying: cy.its() errored because the property: request does not exist on your subject.
cy.its() waited for the specified property request to exist, but it never did.
If you do not expect the property request to exist, then add an assertion such as:
cy.wrap({ foo: 'bar' }).its('quux').should('not.exist')
Run Code Online (Sandbox Code Playgroud)
如果我注释掉状态代码断言,则会引发此新错误:测试的对象必须是数组、映射、对象、集合、字符串或弱集,但给定对象。
任何帮助让这项工作正常进行将不胜感激!
cypress ×1