cypress: [7.0.1]Bug: uploading a fixture break Cypress
I upgraded Cypress from 5.5.0 to 6.8.0 noticing a issue with the uploading from images as fixtures. This issue was present also when one manually uploads a image to the tested site. Since this issue, manifested after the update, I updated to 7.0.0 (and to 7.0.1 for that matter).
Current behavior
Cypress breaks when uploading an Image, thus stoping execution.
Test code to reproduce
This is the breaking part of the test, while “cy.wait(‘imageRequest’)” is open during it it breaks.
Due to some uncertainty in confindelity I sadly can’t publish the full test.
cy.fixture('testimage.png').as('image')
cy.get('.block').last().within(() => {
cy.get('.grid-row .grid-column .plugin-image .form input[type=file]').then(function (el) {
cy.wait('@imageRequest')
// cy.wait('@pageSaveRequest')
// convert the image base64 string to a blob
const blob = Cypress.Blob.base64StringToBlob(this.image, 'image/png')
const file = new File([blob], 'testimage.png', { type: 'image/png' })
const list = new DataTransfer()
list.items.add(file)
const myFileList = list.files
el[0].files = myFileList
el[0].dispatchEvent(new Event('change', { bubbles: true }))
})
})
Error Message
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 (137)
at write_ (_http_outgoing.js:696:11)
at ClientRequest.write (_http_outgoing.js:661:15)
at Request.write (/path/from/userTo/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:1496:27)
at /path/from/userTo/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:546:20
at Array.forEach (<anonymous>:null:null)
at end (/path/from/userTo/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:545:23)
at Immediate._onImmediate (/path/from/userTo/Caches/Cypress/7.0.1/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 (137)
at write_ (_http_outgoing.js:696:11)
at ClientRequest.write (_http_outgoing.js:661:15)
at Request.write (/path/from/userTo/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:1496:27)
at /path/from/userTo/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:546:20
at Array.forEach (<anonymous>:null:null)
at end (/path/from/userTo/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:545:23)
at Immediate._onImmediate (/path/from/userTo/Caches/Cypress/7.0.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/request.js:578:7)
at processImmediate (internal/timers.js:461:21)
Versions
It works in 5.5.0, from 6.0.1 it doesn’t work but did not brake, from 7.0.0 it breaks Cypress.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 22 (16 by maintainers)
Release 7.2.0 didn’t fix our issue. Will try to create a reproducible test suite.
@jennifer-shehane I already tested it on my test suite mentioned above and it works (on darwin).
We merged in a fix for the other issue https://github.com/cypress-io/cypress/pull/15946, so you may try the next release around Monday to see if this issue is resolved if it is actually related.
There’s an example in this issue that may or may not be related. In that example, there is no uploading from within Cypress, but simply uploading a video within their app that is running inside Cypress. See https://github.com/cypress-io/cypress/issues/16223#issuecomment-827725156
@jennifer-shehane Here’s a a test suite (using yarn) with both a
cy.route()andcy.intercept()version of the same test. The former success without a problem. The latter causes the crash above.@verheyenkoen We’ll have a feature release on Monday like we do every 2 weeks, barring any complications on the release day. You could technically download the pre-release if you want to follow instructions on the specific commit: https://github.com/cypress-io/cypress/commit/a7028352c6297b4d8e8b01f2d29de7af7f725e80#commitcomment-49866616
Having a very similar (if not the same) issue.
@LukasM937 Can you post your full test. I guess you are starting off with a
cy.interceptto alias the route to wait on.In my case I was in the process of migrating from
cy.routetocy.interceptand the former is still working while the latter is causing the crash, so the bug is probablycy.interceptrelated.