Testing a redirect to a new route with Cypress

前端 未结 2 1006
情书的邮戳
情书的邮戳 2021-02-05 02:30

I am using Cypress for testing my web application.

This snippet currently works and will submit a new thing:

describe(\'The Create Page\', () => {
  i         


        
2条回答
  •  南笙
    南笙 (楼主)
    2021-02-05 03:11

    What you need to do is assert that the url is in the expected state.

    There are many commands in Cypress that can be used to make assertions about the url. Specifically, cy.url(), cy.location() or cy.hash() may meet your requirements. Probably the best example for your use case would be this:

    cy.location('pathname').should('eq', '/newthing/:id')
    

提交回复
热议问题