cypress: Screenshot file name too long warning when Bytes exceeded
Current behavior:
Currently I use BDD to document acceptance test cases, each test scenario is well detailed, Cypress uses the description of “it” to create the screenshot file name, but when “it” exceeds 255 characters it is not possible to create the screenshot file.
6) As a quality manager, i would like to query the occurence history to find information about them GIVEN that im onthe search sreen, WHEN i fill in the ocurrence date fields, check the only delayed ones box and click on the filter button, THEN i see the filtered results:
Error: ENAMETOOLONG: name too long, open '/home/node/cypress/screenshots/tools/us6.spec.js/As a quality manager iwould like to query the occurence history to find information about them -- GIVEN that im on the search sreen WHEN i fill in the ocurrence date fields check the only delayed ones box and click on the filter button THEN i see the filteredresults (failed).png'
Desired behavior:
- I hope Cypress allows me to change the name of the destination file from the screenshot before it writes it.
- Or, I hope Cypress will worry about the size of the file before it writes it and limits it to 255 characters.
Steps to reproduce:
- Create a test case with “it” description too long, bigger then 255 caracteres.
- Make a test case broken.
- Run tests.
- Look the verbose log, the screenshot not was created.
Versions
Cypress: 3.0.3 Browser: Chrome 67
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 11
- Comments: 16 (8 by maintainers)
+1
+1
Thank’s for response @chrisbreiding , we are running on Ubuntu 16, Ubuntu 18 and Docker image cypress/browsers:chrome67
The original issue opened by @rafaelcaviquioli was fixed, by this PR: #2635
The issue @AlDemion and @kuznetsovaOk are running in to seems to be caused by the difference between
String.lengthandBuffer.byteLengthas described here: https://github.com/cypress-io/cypress/issues/2403#issuecomment-551872521I’ve opened a PR that truncates filenames to a maximum of bytes on all operating systems.
@jbergknoff-rival you can try building from my PR and see if it fixes your issue, or if you want, you can share the filenames that are causing problems and I can try to see. Any Unicode character could cause this problem.
If you don’t have any Unicode in your filenames, could you also share debug logs from the time that issue occurs?
The patch should be simple enough, if someone having this issue wants to open a PR. We most likely just need to use
Buffer.byteLengthinstead ofString.prototype.lengthhere:https://github.com/cypress-io/cypress/blob/98063aec64fe42df6680f227a2aaf5692b73af88/packages/server/lib/screenshots.coffee#L329