1. cy.intercept is not a function

      1. it('.as() - alias a route for later use', () => {
      2. // Alias the route to wait for its response
      3. cy.intercept('GET', '**/comments/*').as('getComment')
      4. // we have code that gets a comment when
      5. // the button is clicked in scripts.js
      6. cy.get('.network-btn').click()
      7. // https://on.cypress.io/wait
      8. cy.wait('@getComment').its('response.statusCode').should('eq', 200)
      9. })

      因为安装的cypress版本为5.6.0,使用cy.intercept必须升级到v6.0以上,6.0.0重命名cy.route2()为cy.intercept().
      如果保持5.6.0必须在cypress.json文件中添加如下:

      1. "experimentalNetworkStubbing": true