Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshot naming on test failure #27665

Open
XavierDupessey opened this issue Aug 25, 2023 · 6 comments
Open

Screenshot naming on test failure #27665

XavierDupessey opened this issue Aug 25, 2023 · 6 comments

Comments

@XavierDupessey
Copy link

XavierDupessey commented Aug 25, 2023

Current behavior

Hello,

The documentation says:

For a failure screenshot, the default naming scheme is used and the name is appended with (failed):
{screenshotsFolder}/{adjustedSpecPath}/{testName} (failed).png

Cf https://docs.cypress.io/api/commands/screenshot#Naming-conventions

However, it seams it is not always the case. For example, when an error occurs in a before/after(each) hook, a screenshot can be named: cypress\screenshots\commerce-segment-creation.e2e.cy.ts\Should create commerce segment -- after all hook CheckEmptiedStubRequests (failed).png

As you can see, the screenshot name includes the function that failed (CheckEmptiedStubRequests). It makes them unpredictable and impossible to attach in the report as test context (cf addContext of mochawesome).

Desired behavior

The screenshot naming should be predictable.

The best would be having an option to customize the pattern, or at least make it possible to name them with the test UUID, e.g. {screenshotsFolder}/be7dae96-573b-420f-bc59-2ec273dd4396 (failed).png. AFAIK, hooks also have a UUID.

Test code to reproduce

Cypress Version

12.17.2

Node version

16.14.0

Operating System

Windows 10 Enterprise 22H2

Debug Logs

No response

Other

Thank you

@s1046
Copy link

s1046 commented Sep 6, 2023

i met the question too, a scene is the test name is too long, greater than 256 words ,the opertation system cut the string,can give me some suggestion solve this,ths

@JoeyLi-1
Copy link

I met the similar issue that the screenshot name seems unpredictable. And after test for days, seems the {adjustedSpecPath} === Cypress.spec.relative - screenshotsFolder(the folder levels).
E.g.
Cypress.spec.relative = cypress/e2e/test/mock_folder/mockSpec.js
screenshotsFolder = cypress/report/assets
then the final screenshot name is something like: cypress/report/assets/mock_folder/mockSpec.js/xxxx--xxxx(failed).png

Did not have real evidence, I mean something from the code. It might just be a coincidence. But this workaround seems solve our problem.

@cornelcgm
Copy link

Hi @jennifer-shehane,
We are experiencing blockers on this behavior also. Can this please be evaluated, put in the proper queue?
Any feedback is appreciated.

@djc6996
Copy link

djc6996 commented Apr 18, 2024

Hi @jennifer-shehane ,

there is a way to configure the default name of the screenshot (not using the cy.screenshot() command).

We are runnin in our CI (gitlab):
osName --> linux
osVersion --> Debian -
Cypress version --> 13.6.0

In the after:screeshot API the name of the screenshot is a concatenation of the description of the keyword (describe, context, it) if the length of the concatenation is more then 255 chars it will be truncated.

For what i understand in this API is not possible use the test informations, i am wrong?

I need to manupulate the screenshot file name to be accessible in a local report (not cypress cloud)

Do you have some suggestion?

For the moment i ask to manage this 'problem' to not exceeding the chars, taken in consideration the whole concatenation.

Thank you in advance.
DJC

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Oct 16, 2024
@XavierDupessey
Copy link
Author

Still relevant today.

@cypress-app-bot cypress-app-bot removed the stale no activity on this issue for a long period label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants