Cypress - Test Organization and Patterns
You wrote this API-first setup code in Cypress:
But the test fails with "Cannot read property 'then' of undefined". What is the likely cause?
cy.request('POST', '/api/items', {name: 'Book'})
.then((res) => {
expect(res.status).to.eq(200)
cy.wrap(res.body.id).as('itemId')
})
cy.get('@itemId').then((id) => {
cy.visit(`/items/${id}`)
})But the test fails with "Cannot read property 'then' of undefined". What is the likely cause?
