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

Mocking a route with an empty response body doesn't show the XHR call as being stubbed #8018

Closed
andreiduca opened this issue Jul 17, 2020 · 4 comments · Fixed by #8033
Closed
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug

Comments

@andreiduca
Copy link

andreiduca commented Jul 17, 2020

Current behavior:

Mocking a route with an empty response body

cy.route('/sockjs-node/**', '').as('nodeSock');

incorrectly shows the XHR call not being stubbed:

Mocking the response body with a non-falsy value does produce the correct outcome:

cy.route('/sockjs-node/**', '1').as('nodeSock');

**Note: the request IS marked as stubbed in the Console in both cases:

Desired behavior:

Both examples should show the call as (xhr stub) in the test runner.

Test code to reproduce

  1. Mock any route with an empty response body.
  2. Observe the mocked XHR call note being shown as stubbed.

Versions

Cypress@4.10, node 12.16.3, macOS 10.15.5

@jennifer-shehane
Copy link
Member

Yeah, I feel like this is solely a visual bug in the Test Runner's Command Log. This test passes, but it doesn't show up as xhr stub in the Command Log.

So, I don't this is actually affecting any behavior.

it('fails to show as stub in command log', () => {
  cy.visit('https://example.cypress.io/commands/aliasing')
  cy.server()
  cy.route('GET', 'comments/*', '').as('getComment')

  cy.get('.network-btn').click()
  cy.wait('@getComment').then((xhr) => {
    expect(xhr.response.body).to.eq('')
  })
})

Screen Shot 2020-07-20 at 3 54 19 PM

Looks like a check here that is returning false when the response is ''. https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/xhr.js#L44:L44

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jul 20, 2020
@jennifer-shehane jennifer-shehane added the pkg/driver This is due to an issue in the packages/driver directory label Jul 20, 2020
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: ready for work The issue is reproducible and in scope labels Jul 20, 2020
@jennifer-shehane
Copy link
Member

Opened PR here: #8033

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 20, 2020

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

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Jul 20, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 21, 2020

Released in 4.11.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.11.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jul 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug
Projects
None yet
2 participants