Playwright Test setup
Use Playwright Test's JSON reporter for diagnosis, repair, and validation in a JavaScript or TypeScript project. A Playwright JUnit or CTRF report supports diagnosis. Compare report formats and frameworks.
Configure Playwright
Install kwikqa in the package that runs the tests. The example uses Chromium and looks for specs in tests/. Keep your existing projects, authentication, and web server settings when adding the reporter to a project.
npm i -D kwikqa @playwright/test
npx playwright install chromium
// playwright.config.ts
import { defineConfig } from "@playwright/test";
export default defineConfig({
testDir: "./tests",
reporter: [
["list"],
["json", { outputFile: "test-results/kwikqa-report.json" }],
],
use: {
browserName: "chromium",
trace: "retain-on-failure",
screenshot: "only-on-failure",
},
});
Keep test-results/ with the JSON report. Trace and screenshot entries point to files from the run. If your usual trace policy leaves a failing attempt without evidence, analyze --capture can rerun the failures with tracing after you approve.
Analyze a failing run
npx playwright test
npx kwikqa analyze --report test-results/kwikqa-report.json --html
Run the two commands in order, including after Playwright exits with a failure. Add --local for an account-free preview with failure groups and available evidence. For a model diagnosis, sign in and review the evidence request. Follow your first repair to initialize a policy, review a patch, and validate it.
Merge Playwright shards in GitHub Actions
Commit the following merge config next to your normal config. The merge job needs the same lockfile, source checkout, Playwright version, and test directory as the shard jobs. Use a single project or give each project a unique name in your normal Playwright config. Playwright 1.64 can omit project IDs and repeat project config entries in merged JSON. The workflow restores the normal IDs from the project names and keeps the extracted trace and screenshot files in the workspace for KwikQA.
// playwright.merge.config.ts
import { defineConfig } from "@playwright/test";
export default defineConfig({
testDir: "./tests",
reporter: [["json", { outputFile: "merged-playwright.json" }]],
});
Save this as .github/workflows/playwright-sharded.yml. It produces a local KwikQA report on a failed test run without secrets. The original test jobs stay failed. For hosted diagnosis and a PR comment, use the KwikQA Action in the merge job with the merged report as its input.
name: Sharded Playwright
on: [pull_request, workflow_dispatch]
permissions:
contents: read
jobs:
e2e:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: "24"
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npx playwright test --reporter=blob --shard=${{ matrix.shard }}/2
- if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: playwright-blob-${{ matrix.shard }}
path: blob-report/*.zip
if-no-files-found: warn
merge:
needs: e2e
if: ${{ !cancelled() && needs.e2e.result == 'failure' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: "24"
- run: npm ci
- uses: actions/download-artifact@v8
with:
pattern: playwright-blob-*
path: all-blob-reports
merge-multiple: true
- run: npx playwright merge-reports --config=playwright.merge.config.ts all-blob-reports
- name: Prepare merged JSON for KwikQA
run: |
node --input-type=commonjs <<'NODE'
const fs = require("node:fs");
const path = "merged-playwright.json";
const report = JSON.parse(fs.readFileSync(path, "utf8"));
const projects = new Map();
for (const project of report.config.projects) {
projects.set(project.name, { ...project, id: project.id ?? project.name });
}
report.config.projects = [...projects.values()];
function restoreProjectIds(suite) {
for (const spec of suite.specs ?? []) {
for (const test of spec.tests) {
test.projectId ??= projects.get(test.projectName).id;
}
}
for (const nested of suite.suites ?? []) restoreProjectIds(nested);
}
for (const suite of report.suites) restoreProjectIds(suite);
fs.writeFileSync(path, JSON.stringify(report));
NODE
- run: npx kwikqa ci --local --report merged-playwright.json
- if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: kwikqa-report
path: kwikqa-report.html
if-no-files-found: warn
See Playwright sharding for balancing shards and merging across environments.