playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature]: Label screenshots made in playwright with test file name

Open mastrzyz opened this issue 1 year ago • 4 comments

🚀 Feature Request

Append the sanitized test name to the automatic screenshot mechanism of Playwright.

Why?

Currently the names are very generic and cause conflicts in CI/CD Systems like Azure Devops when we have multiple jobs failing with the same generic name:

Image

It's also not very clear which number responds to which testcase when we are able to upload:

Image

Example

Fix!

Added the sanitized file name, a good example of how this looks like are the fixed unit tests :

Image

This will allow us to find the artifact easier and not conflict in CI/CD systems like in Azure Devops

Motivation

This is purely a CI/CD Improvement for Playwright integration for us, we have a massively parallel system running hundreds of tests across multiple shards

mastrzyz avatar Oct 16 '24 15:10 mastrzyz

@mastrzyz Thank you for filing the issue!

Don't you have the same problem with traces, all named trace.zip? It seems like the better solution is to update your reporter to include the test name in any attachments it generates, since these are presented as a plain list, not grouped by test.

dgozman avatar Oct 17 '24 12:10 dgozman

Sorry @dgozman , I'm not using any custom reporter and relying on the existing Playwright reporters which are outputting trace.zip and screenshot1.png.

mastrzyz avatar Oct 17 '24 17:10 mastrzyz

@mastrzyz In this case, why do you only focus on the screenshots? I'd think that trace.zip would be equally important. Do I miss something?

If I understand correctly, you are using junit reporter that is uploaded to Azure DevOps through this task, don't you? Perhaps we can improve that part instead? Why does it not show the full attachment path? Reading this post, I would think the full attachment path that already includes test path could be shown. Not to mentioning that it's a part of the specific test output.

dgozman avatar Oct 18 '24 11:10 dgozman

You know to tell you the truth, why don't I see this failure for trace.zip!

Image

Could it be that trace.zip is only one? we have retries enabled so I wonder if we take screenshots in first attempt and then seccond also takes and collides

mastrzyz avatar Oct 18 '24 21:10 mastrzyz

@mastrzyz Perhaps you should set both trace and screenshot to 'on-first-retry'?

dgozman avatar Oct 21 '24 07:10 dgozman

  : { trace: "on-first-retry", video: "on-first-retry" }), yeah we have that already

mastrzyz avatar Oct 21 '24 20:10 mastrzyz

  : { trace: "on-first-retry", video: "on-first-retry" }), yeah we have that already

Sorry, I do not quite understand. The snippet does not show the screenshot setting. I think that if you set it to on-first-retry similarly to trace/video, your warnings will disappear. Could you please check that?

dgozman avatar Oct 23 '24 10:10 dgozman

@dgozman , I don't think that is possible -> Image

but I Get what you mean, this would solve it

mastrzyz avatar Oct 23 '24 15:10 mastrzyz

@mastrzyz Indeed, my mistake. I think we can introduce screenshot: 'on-first-failure' mode that would limit the total number of screenshots per test to one, and most likely fix your issue.

dgozman avatar Oct 24 '24 09:10 dgozman

Linking https://github.com/microsoft/playwright/issues/30701

mxschmitt avatar Oct 24 '24 09:10 mxschmitt

Yep @dgozman , appreciate this and sorry for the confusion hah!

mastrzyz avatar Oct 29 '24 15:10 mastrzyz