In this lesson well stub a POST
request and use Cypress commands to fill in and submit a form. We’ll wait for the submission to resolve and then assert that the new item was added to the list.
Why does cy.route include that response; why not just a status 200?
Because our application code uses the response to update the UI. We need to stub the response body to test the intended behavior of the application.
Can't we just place cy.seedAndVisit()
before cy.route(...)
as it already contains cy.server()
?
Are there negative sides to calling cy.server()
several times?
Does creating that stub mean it won't actually send to the real database when you hit enter? So... it just knows that you created a stub beforehand and will return the post response?
You're correct @Jonathan - the test will use the stubbed out data without having to send any requests or fetch from the database