playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature]: Global metadata in HTML report

Open martin-simon-LS opened this issue 6 months ago • 3 comments

🚀 Feature Request

Hi, I'd like to have the option to modify HTML report title based on the test execution.

UseCase: Run API tests which in response header return the current version of the application under test. This version appears in the report title.

I've tried to set the title HTML reporter option dynamically based on ENV variable. But the playwright.config.ts is loaded before the test execution so I cannot affect it retrospectively.

So I've tried to set it dynamically using process.env.PLAYWRIGHT_HTML_TITLE = App Version: ${version} directly in the test, but the value (title) has not changed.

Example

No response

Motivation

Possibility to ehnace the HTML test report by additional information.

martin-simon-LS avatar Jun 23 '25 13:06 martin-simon-LS

Hi! I understand you want to display per-run metadata in the HTML report. Do you specifically care about it being in the title, or would it also be OK if it was displayed in some fold-out metadata field?

Skn0tt avatar Jun 24 '25 09:06 Skn0tt

Hey, no it doesn't need to be in the title at all. It's just a field that already exists, so I wanted to make use of it. A separate section able to contain optional metadata connected to the run would be much better. Right now, I have it in the stdout log for each test, which is not ideal since it isn't promiment enough for people to see at first glance.

martin-simon-LS avatar Jun 24 '25 10:06 martin-simon-LS

Discussed this with the team. I'll look into ensuring you can set PLAYWRIGHT_HTML_TITLE from inside a test or global teardown.

Skn0tt avatar Jun 24 '25 16:06 Skn0tt

Setting it from inside a test is a bigger change, but https://github.com/microsoft/playwright/pull/36433 ensures that you can set the PLAYWRIGHT_HTML_TITLE var from inside global teardown. Take a look at the included test for an example of how you can get the value from inside a test.

Skn0tt avatar Jun 25 '25 08:06 Skn0tt