selectFile from fixture will omit file name if used in two consequent tests
See original GitHub issueCurrent behavior
I have two tests uploading pdf file like this
cy.fixture('PDF/ThisIsTest.pdf', { encoding: null }).as('file')
cy.get(personalDetails.tbModal.id).should('be.visible')
cy.get(personalDetails.tbModal.fileInput).selectFile( '@file', { force: true })
If I run only one test it works fine, but if I run for example absolutely the same test twice (for example just by duplicating its code) then for the second test file is attached without name and endpoint returns error file not found. Workaround is to specify file name directly or use different fixure files and you can run as many tests as you want.
cy.fixture('PDF/ThisIsTest.pdf', { encoding: null }).as('file')
cy.get(personalDetails.tbModal.id).should('be.visible')
cy.get(personalDetails.tbModal.fileInput).selectFile({ contents: '@file', fileName: 'file.pdf' }, { force: true })
Desired behavior
It should be possible to just use the same fixture without specifying file name.
Test code to reproduce
cy.fixture('PDF/ThisIsTest.pdf', { encoding: null }).as('file')
cy.get(personalDetails.tbModal.id).should('be.visible')
cy.get(personalDetails.tbModal.fileInput).selectFile( '@file', { force: true })
Cypress Version
9.7.0
Other
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Cypress- SelectFile() Not working as expected in Chrome
The code when running the test through FF runs as expected and the file is uploaded with a 200 on the post request....
Read more >Easy-Wire™ Software Manual - Cirris
4.4.2 Test Process options . ... Click the text box and enter a station name used to ... There is no undo function...
Read more >Changelog - Cypress Documentation
Fixed an issue with Angular Component Testing where urls within SASS/SCSS files were not being correctly resolved which could result in incomplete styling....
Read more >Touchstone Docs
More information about Fixtures can be found in the FHIR Testing ... /_reference/resources/filename.json” as the reference value. ... and select File :.
Read more >MTS TestSuite™ TW Essential User Guide
MTS TestSuite Folders and Files Management Overview ... The left section contains the test definition tree, which is used to guide your progress...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
From the opening post in this issue:
Specifying the file name explicitly always works.
I was able to reproduce the issue using the following test project: https://github.com/mschile/cypress-test-tiny-issue-21936.