Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cy.intercept: delay is not working on 204 No Content #15188

Closed
runarb opened this issue Feb 23, 2021 · 6 comments · Fixed by #17126
Closed

cy.intercept: delay is not working on 204 No Content #15188

runarb opened this issue Feb 23, 2021 · 6 comments · Fixed by #17126

Comments

@runarb
Copy link

runarb commented Feb 23, 2021

Current 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:
image

Second spec:
image

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
@jennifer-shehane
Copy link
Member

I can recreate this issue. The delay is not applying for 204 content.

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
});

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();

  // resolves immediately, should fail with only 1sec timeout
  cy.wait('@success', { timeout: 1000 }); 
});

Screen Shot 2021-02-23 at 8 23 45 PM

@jennifer-shehane jennifer-shehane added type: unexpected behavior User expected result, but got another stage: ready for work The issue is reproducible and in scope type: bug and removed type: unexpected behavior User expected result, but got another labels Feb 24, 2021
@rsheasby
Copy link

Is there any movement on this issue, or at least a workaround?

@hugocruz
Copy link

Any update on this?

@jennifer-shehane
Copy link
Member

No work has been done on this issue. We're open to reviewing a pull request to fix this unexpected behavior.

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Jun 28, 2021
@cypress-bot cypress-bot bot added stage: waiting stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: waiting labels Jul 12, 2021
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jul 13, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 13, 2021

The code for this is done in cypress-io/cypress#17126, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 20, 2021

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.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jul 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants