Skip to content

Commit b7e65b3

Browse files
authored
add test checking status code after cy.intercept (#594)
1 parent 8119246 commit b7e65b3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

examples/stubbing-spying__intercept/cypress/integration/spy-on-fetch-spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ describe('intercept', () => {
3535
// there should be three users displayed on the page
3636
cy.get('.user').should('have.length', 3)
3737
})
38+
39+
it('checks the status code', () => {
40+
cy.intercept('/users').as('users')
41+
cy.get('#load-five-users').click()
42+
cy.wait('@users').its('response').then((response) => {
43+
expect(response).to.include({
44+
statusCode: 200,
45+
statusMessage: 'OK',
46+
})
47+
48+
// or check every property separately
49+
expect(response).property('statusCode').to.equal(200)
50+
expect(response).property('body').to.have.length(5)
51+
})
52+
})
3853
})
3954

4055
context('uses query', () => {

0 commit comments

Comments
 (0)