cy.intercept is not a function
it('.as() - alias a route for later use', () => {
// Alias the route to wait for its response
cy.intercept('GET', '**/comments/*').as('getComment')
// we have code that gets a comment when
// the button is clicked in scripts.js
cy.get('.network-btn').click()
// https://on.cypress.io/wait
cy.wait('@getComment').its('response.statusCode').should('eq', 200)
})
因为安装的cypress版本为5.6.0,使用cy.intercept必须升级到v6.0以上,6.0.0重命名cy.route2()为cy.intercept().
如果保持5.6.0必须在cypress.json文件中添加如下:"experimentalNetworkStubbing": true