柏树拦截url响应使用柏树-黄瓜不返回响应



这是我的黄瓜when语句的一个例子

basic-interaction.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: expected {Object (id, routeHandlerId,…)}有属性'response.statusCode'

AssertionError: expected {Object (id, routeHandlerId,…)}具有属性'status'

请尝试cy.wait(`@${aliasHref}`).its('response.statusCode').should('eq', 200)

相关内容

  • 没有找到相关文章

最新更新