Skip to content

Commit

Permalink
chore: improve playwright test reporting on github ci (#7650)
Browse files Browse the repository at this point in the history
* ci: improve playwright test reporting on github ci

* ci: temporarily use test command in packages/kit to avoid turbo prefix in output

* fix: replace noisy github reporter with dot reporter

* fix: restore original test command
  • Loading branch information
dominikg authored Feb 14, 2023
1 parent e5bd643 commit 3726d2e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
35 changes: 35 additions & 0 deletions packages/kit/test/github-flaky-warning-reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @class
* @implements {import('@playwright/test/reporter').Reporter}
*/
export default class GithubFlakyWarningReporter {
/**
* @type {{ file: string; line: number; title: string; message: string; }[]}
*/
_flaky = [];

onBegin() {
this._flaky = [];
}
/**
* @param test {import('@playwright/test/reporter').TestCase}
*/
onTestEnd(test) {
if (test.outcome() === 'flaky') {
const { file, line } = test.location;
const title = `flaky test: ${test.title}`;
const message = `retries: ${test.retries}`;
this._flaky.push({ file, line, title, message });
}
}

onEnd() {
this._flaky.forEach(({ file, line, title, message }) => {
console.log(`::warning file=${file},line=${line},title=${title}::${message}`);
});
}

printsToStdio() {
return true;
}
}
10 changes: 9 additions & 1 deletion packages/kit/test/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import fs from 'fs';
import path from 'path';
import http from 'http';
import { test as base, devices } from '@playwright/test';
import { fileURLToPath } from 'url';

export const test = base.extend({
app: async ({ page }, use) => {
Expand Down Expand Up @@ -245,5 +247,11 @@ export const config = {
screenshot: 'only-on-failure',
trace: 'retain-on-failure'
},
workers: process.env.CI ? 2 : undefined
workers: process.env.CI ? 2 : undefined,
reporter: process.env.CI
? [
['dot'],
[path.resolve(fileURLToPath(import.meta.url), '../github-flaky-warning-reporter.js')]
]
: 'list'
};

0 comments on commit 3726d2e

Please sign in to comment.