abramenal / cypress-file-upload

File upload testing made easy
https://npm.im/cypress-file-upload
MIT License
496 stars 89 forks source link

[Bug] ERR_INVALID_ARG_TYPE when uploading a file with the new cypress v7.0.0 #289

Open andrei10k opened 3 years ago

andrei10k commented 3 years ago

Current behavior:

with the new cypress v7.0.0 and cypress-file-upload v5.0.4 the pdf upload is not working. i got the following error:

TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer or Uint8Array. Received type number (45)
    at write_ (_http_outgoing.js:696:11)
    at ClientRequest.write (_http_outgoing.js:661:15)
    at Request.write (/Users/xxx/Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:1496:27)
    at /Users/xxx/Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:546:20
    at Array.forEach (<anonymous>:null:null)
    at end (/Users/xxx/Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:545:23)
    at Immediate._onImmediate (/Users/xxx/Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:578:7)
    at processImmediate (internal/timers.js:461:21)
 {
  code: 'ERR_INVALID_ARG_TYPE'
}
TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer or Uint8Array. Received type number (45)
    at write_ (_http_outgoing.js:696:11)
    at ClientRequest.write (_http_outgoing.js:661:15)
    at Request.write (/Users/xxx/Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:1496:27)
    at /Users/xxx/Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:546:20
    at Array.forEach (<anonymous>:null:null)
    at end (/Users/xxx/Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:545:23)
    at Immediate._onImmediate (/Users/xxx/Library/Caches/Cypress/7.0.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:578:7)
    at processImmediate (internal/timers.js:461:21)

✨  Done in 811.82s.

Desired behavior:

the upload should work as with version 6.8.0

Steps to reproduce: (app code and test code)

const yourFixturePath = 'template.pdf'
    cy.get('[data-cy="upload_btn"]').attachFile({
      filePath: yourFixturePath,
      mimeType: 'application/pdf',
      encoding: 'binary'
    })

Versions

cypress v7.0.0, cypress-file-upload v5.0.4, macos bug sur, chrome

abramenal commented 3 years ago

Hi @andrei10k Thanks for submitting the issue! Consider this as top priority issue, working on it

slinkardbrandon commented 3 years ago

Thanks for looking into this @abramenal, is there anything we can do to help? I just started running into this as well. I'm happy to investigate it a bit but I don't want to step on your toes. If I can help at all I would love to though.

abramenal commented 3 years ago

I couldn't reproduce the issue locally. Here is what I've used:

cypress@7.0.0 and @7.0.1
Electron@89
Chrome@89

It would be really nice if someone can set up a small repo with reproducible example. cc @slinkardbrandon

daggmano commented 3 years ago

Sounds like it may be a Cypress issue? See https://github.com/cypress-io/cypress/issues/15901

tagliala commented 3 years ago

cypress-io/cypress#15901 should have been fixed in 7.2.0

btw, I'm successfully using 7.2.0 w 5.0.6 version of this gem and file uploads works on Chrome

donalmurtagh commented 3 years ago

I've tested with 7.2.0 and the issue still exists. See this comment for further details. It looks like this issue may be caused by this unresolved Cypress bug https://github.com/cypress-io/cypress/issues/15898

jozso39 commented 3 years ago

This problem still exists for me as well on cypress 7.2.0 The crash doesnt occur on the file upload step, but only when trying to cy.intercept the request that uploads the file.

It worked in cypress 6.8.0 :( So its probably a Cypress problem

cuadllop commented 3 years ago

Still happening to me as well in 7.2.0

The last version where we have checked to be working is 6.9.1

strass commented 3 years ago

the fix in 7.3.0 pre-release here worked for me: https://github.com/cypress-io/cypress/issues/15898#issuecomment-831987480