cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Cypress intercept corrupting msgp file

Open jeromeBor opened this issue 3 years ago • 1 comments

Current behavior

I'm passing to cy.intercept a message pack file, and when I receveive from respondse, it, it's not the same as the one I passed.

Desired behavior

The intercepted message pack file should be the same before and after the intercept

Test code to reproduce

1 - get a message pack file 2 -

cy.intercept('**a request**', {fixture: "fixtures_folder.json"}) // ( containing an array with one of more url as string)

3 -

cy.intercept('**/given_url_from_fixture.msgp**', (req) => {
  req.reply({
    headers: {'content-type': 'application/octet-stream'},
    fixture: 'messagepackfile.msgp'
  })
})

Saved file image Intercepted file image

20/09 update : I tried to pass a second argument to fixture, as the docs mentions it "You can specify null as the encoding in order to read the file as a Cypress.Buffer instance instead." but it's throw an error "Unable to parse". Alos tried with other argument, like UTF8, still not working

My code now looks like this :

      cy.intercept('**/14020_1662941218.msgp**', {
          fixture: '14020_1662941219.msgp, null',
          headers: {'content-type': 'application/octet-stream'},
      })

Cypress Version

9.3.1

Node version

16.13.2

Operating System

win 10

Debug Logs

No response

Other

No response

jeromeBor avatar Sep 19 '22 07:09 jeromeBor

I'm trying to verify this issue by reproducing it, but having some difficulty. Could you provide an example messagepack file? Also, how are you logging the ArrayBuffer for the saved file and for a intercepted file?

chrisbreiding avatar Sep 20 '22 20:09 chrisbreiding

Hi and thanks for the answer ! Unfortunatly, our message pack file and kind of confidential :/ I'm setting a debugger in the method that decode the messagepack file, and the arrayBuffer byteLength is not the same for the 2 executions. First, I clicked on my app to fetch mannualy this file, and I checked the debugger on the method that decoded it. Plus, I also saved the file in the devtool network panel by double clicking on it. Then, I just set the cy.intercept() with the saved file at the very moment when the app should download the message pack from the given url.

jeromeBor avatar Sep 22 '22 10:09 jeromeBor

Could you provide a reproduction of this issue using https://github.com/cypress-io/cypress-test-tiny as your template? Without a reproducible example, we don't have a path forward to investigate this.

chrisbreiding avatar Sep 22 '22 14:09 chrisbreiding

Right now there doesn't seem to be enough information to reproduce the problem on our end. Unless we receive a reliable reproduction, we'll eventually have to close this issue until we can reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.

Please provide a reproducible example of the issue you're encountering. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.

mjhenkes avatar Oct 03 '22 17:10 mjhenkes