field for configuration:
import { defineConfig } from '@playwright/test';
export default defineConfig({
metadata: 'acceptance tests',
});
At the time of writing (Playwright v1.49), it states:
Metadata that will be put directly into the test report serialized as JSON
But there's a catch: adding this configuration won't show any metadata in the report. If you're using TypeScript, you'll also see an error for the provided example:
Type 'string' is not assignable to type 'Metadata'.
Clearly, the documentation is outdated, but metadata in reports is indeed possible.
The Real Metadata Configuration
After diving into Playwright’s
Automating Metadata Population
Manually filling metadata fields isn't practical, especially in dynamic environments like CI/CD pipelines. Automating this process ensures accurate and consistent metadata without manual effort.
Third-Party packages
To automate the process, you can utilize any third-party package that . Playwright supports a hidden configuration field "@playwright/test", where you can define plugins.
Here’s an example of enabling the gitCommitInfo plugin:
import { defineConfig } from '@playwright/test';
import { gitCommitInfo } from 'playwright/lib/plugins';
export default defineConfig({
reporter: 'html',
// @ts-expect-error
'@playwright/test': {
plugins: [gitCommitInfo()]
},
});
What Does the gitCommitInfo Plugin Do?
This plugin
Other Plugins
I was curious, are there any other hidden plugins in Playwright?
In the as some point. Unfortunately, there are
This approach gives you full control over metadata automation without depending on internal Playwright features.
Optimizing for Parallel Tests
Everything looks good, but there is a performance issue with the code above. Could you guess what is the problem?
Playwright runs tests to the Playwright repo, proposing documentation improvements for metadata field.
Have you tried adding metadata to Playwright reports? Share your experience or challenges in the comments!
SOCIAL SHARE CARD GENERATOR