Hi
I am following a feature request in Git for Playwright to support native report merging and last night someone got it working natively without any 3rd party libraries so I followed the steps and I managed to get it working.
Here is what I did:
Step 1 - Add blob to the playwright reporter
const reportList: ReporterDescription[] = [['list'], ['blob'], ['html', { open: 'never' }]];
Step 2 - Run the tests using 3 shards
npx playwright test --shard=1/3
npx playwright test --shard=2/3
npx playwright test --shard=2/3
Step 3 - Merge the reports
npx playwright merge-reports blob-report --reporter=html
Thats literally it
Im still reluctant to use this without any official support from Playwright but sharing as its really cool
Here is the thread - https://github.com/microsoft/playwright/issues/10437
This thread is trying to answer question "How can I merge reports with multiple shards in Playwright without using any 3rd party libraries?"
Related Ask AI answer for "What are the steps to generate and merge reports from multiple shards in Playwright without using third-party libraries?".
Unfortunately, the HTML reporter in Playwright doesn't support merging reports from multiple shards. But don't worry, there are other ways to get around this.
First, you can use the JSON reporter. This reporter produces a JSON object with all the test run information. Here's how you can write the JSON to a file:
PLAYWRIGHT_JSON_OUTPUT_NAME=results.json npx playwright test --reporter=json
This command will generate a JSON file with your test results.
Alternatively, you can use the JUnit reporter. This reporter produces a JUnit-style XML report. Here's how you can write the report to an XML file:
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit
This command will generate an XML file with your test results in JUnit format.
If you prefer to configure reporters in a configuration file (playwright.config.ts
), you can specify options directly for each reporter type. Here's how you can configure the JSON reporter:
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [['json', { outputFile: 'results.json' }]],
});
And here's how you can configure the JUnit reporter:
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [['junit', { outputFile: 'results.xml' }]],
});
These configurations will generate a JSON file and an XML file respectively, containing all the information about your tests.
To merge these reports into a single report, you'll need to implement a custom solution or explore alternative options outside of Playwright's built-in reporters.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].