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 doesn't handle binary data correctly #16722

Closed
simfeld opened this issue May 28, 2021 · 3 comments · Fixed by #16755
Closed

cy.intercept doesn't handle binary data correctly #16722

simfeld opened this issue May 28, 2021 · 3 comments · Fixed by #16755

Comments

@simfeld
Copy link
Contributor

simfeld commented May 28, 2021

Current behavior

  1. When intercepting a request that returns binary data (for example application/octet-stream) the response is corrupted by cy.intercept.
  2. When trying to stub a request with an ArrayBuffer it is interpreted as JSON.

Desired behavior

  1. Intercepting a request does not alter the response if it is not stubbed.
  2. It is possible to supply an ArrayBuffer to an intercept stub.

Test code to reproduce

Reproduction code is here: https://github.com/simfeld/cypress-intercept-binary. There are three tests:

  1. no intercept: This test succeeds, the response is loaded correctly from the server.
  2. intercept without stub: This test fails. The request is intercepted but not stubbed. The response that arrives in the browser is {} or [123, 125] when interpreted as ArrayBuffer, instead of the response that the server delivers.
  3. intercept with stub: This test fails. The request is intercepted and a stub is returned. The response that arrives in the browser is {} or [123, 125] when interpreted as ArrayBuffer, instead of the stub supplied to the intercept.

Versions

Latest version as of filing this issue (7.4.0)

Related issues

This issue is possibly related: #15038

@simfeld
Copy link
Contributor Author

simfeld commented Jun 1, 2021

Did some digging and found the issue causing intercept to corrupt the response. See draft #16755. With this change the second test "intercept without stub" in the reproduction project passes (while the third one still fails).

@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Jun 10, 2021
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jun 17, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 17, 2021

The code for this is done in cypress-io/cypress#16755, 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 Jun 23, 2021

Released in 7.6.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 23, 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.

2 participants