cy.intercept: delay is not working on 204 No Content
See original GitHub issueCurrent behavior
When using cy.intercept('POST', url, { statusCode: 204, delay: 5000 })
delay
(or delayMs
) is not respected.
Is this intended behavior? If so, why?
When running tests below I see:
First spec:
Second spec:
Desired behavior
When a request responds with 204 No Content delay
(or delayMs
) should work.
Test code to reproduce
it('post a comment 200 OK', () => {
cy.intercept('POST', 'https://jsonplaceholder.cypress.io/comments', {
statusCode: 200,
delay: 5000,
}).as('success');
cy.visit('https://example.cypress.io/commands/network-requests');
cy.get('.network-post-comment').should('have.value', '')
cy.get('.btn-success').click();
cy.wait('@success'); // waits 5000 ms
cy.get('.network-post-comment').should('contain', 'POST successful!')
});
it('post a comment 204 No Content', () => {
cy.intercept('POST', 'https://jsonplaceholder.cypress.io/comments', {
statusCode: 204, // delay is not respected
delay: 5000,
}).as('success');
cy.visit('https://example.cypress.io/commands/network-requests');
cy.get('.network-post-comment').should('have.value', '')
cy.get('.btn-success').click();
cy.wait('@success'); // resolves immediately
cy.get('.network-post-comment').should('contain', 'POST successful!')
});
Versions
- Cypress: 6.5.0
- Chrome: 88.0.4324.182
- MacOS: 10.15.7
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
intercept - Cypress Documentation
cy.intercept can be used solely for spying: to passively listen for matching routes and apply aliases to them without manipulating the request or...
Read more >Cypress intercept does not match route with status 204
I get your point, but that differs a bit from what the problem is: The route /api/security/logout is not recognised as the alias...
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
A few common cy.intercept gotchas and how to avoid them · The intercept was registered too late · cy.wait uses the intercept ·...
Read more >Risk and Prevalence of Developmental Delay in Young ... - NCBI
What's Known on This Subject: Children with congenital heart disease demonstrate a high prevalence of low-severity developmental problems in the areas of ...
Read more >Report - Investigation of the Challenger Accident - GovInfo
the underlying problem which led to the Challenger acci- ... and current astronauts, the Committee could find no evi- ... The content and....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I can recreate this issue. The delay is not applying for 204 content.
Released in
8.0.0
.This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v8.0.0, please open a new issue.