[Feature]: Global metadata in HTML report
🚀 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.
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?
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.
Discussed this with the team. I'll look into ensuring you can set PLAYWRIGHT_HTML_TITLE from inside a test or global teardown.
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.