这是我的黄瓜 when 语句的一个例子
基本交互.js
let aliasHref = 'aliasHref';
import {Given, When, Then} from 'cypress-cucumber-preprocessor/steps';
When(/I click link \'([^\']+)\'/, async (strSelector) => {
cy.get(strSelector).should('have.attr', 'href').then(href => {
cy.intercept(href).as(aliasHref);
});
cy.get(strSelector).click();
});
Then(/I redirect to url \'([^\']+)\'/, (strUrl) => {
cy.wait(`@${aliasHref}`).its('request.url').should('eq', strUrl); // This passes
cy.wait(`@${aliasHref}`).should('have.property', 'response.statusCode', 200); // This fails
// cy.wait(`@${aliasHref}`).should('have.property', 'status', 200); // This fails
});
我不断收到错误
AssertionError: 预期 { Object (id, routeHandlerId, ...) } 具有属性“response.statusCode”
或者
AssertionError: 预期 { Object (id, routeHandlerId, ...) } 具有属性 'status'