Slide 31
Slide 31 text
@amirrustam
it('starts with zero items (fixture)', () => {
// start Cypress network server
// stub route `GET /todos`, return data from fixture file
// THEN visit the page
cy.server()
cy.route('GET', '/todos', ‘fixture:sample-todos').as('todos')
cy.visit('/')
cy
.wait('@todos') // wait for `GET /todos` response
// inspect the server's response
.its('response.body')
.should('have.length', 0)
// then check the DOM
cy.get('li.todo').should('have.length', 0)
})