cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.66k stars 3.16k forks source link

Unable to write a file upload test. Browser tab completely freezes. #28484

Open brandoncollins7 opened 9 months ago

brandoncollins7 commented 9 months ago

Current behavior

I am using the following code to my file uploader to trying and test a file upload action:

cy.get('[data-cy="select-field-id1.type"]').select('identity', {force: true}) cy.fixture('test.png').then((file) => { cy.get('input[type="file"]').attachFile(file) })

When cypress hits this action the browser tab just completely freezes. Can't click anything, can't scroll. No errors.

Desired behavior

File upload should succeed

Test code to reproduce

not able to provide at this time

Cypress Version

13.0.0

Node version

16.16.0

Operating System

Windows

Debug Logs

No response

Other

No response

brandoncollins7 commented 9 months ago

Exact same thing happens when using edge browser.

brandoncollins7 commented 9 months ago

I've broken it down into the smallest project I can. We have a large monorepo with a lot of dependencies that build our file upload component and it's all set up using nx......

but you should be able to just download this repo, pnpm install and run "nx e2e test-crash-e2e --watch". (You may need to restart the test if it times out the first time as sometimes the project itself compiles too slow after the first page hit)

You should see the entire browser lock up as soon as it tries to attach the file to the input control. Confirmed in both Edge and Chrome. I have also tried printing any logs in our FileUpload component but it seems it doesn't even make it that far so I am at a total loss.

https://github.com/brandoncollins7/test-crash

theishinz-maersk commented 5 months ago

This issue sounds very similar to what we experience the last year for our tests. It is a flaky issue, and no error Cypress error is thrown. It is also my experience that the frequency of the issue also depends on the number of tests we run. I can't share any example unfortunately.

We currently only experience it on our CI (we use Cypresses official Github action). The job terminates after being frozen with: "Error: The operation was canceled.".

We currently use Cypress '13.6.6' and we use the official selectFile() function. Earlier we used old versions of cypress and the 'cypress-file-upload' plugin with same issue. I'm curious if any fix is found.