Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(reporter): do not report parallel tests as slow (#11921)

Dmitry Gozman8a5c93436d1d
diff --git a/packages/playwright-test/src/reporters/base.ts b/packages/playwright-test/src/reporters/base.ts
index a779bb2dd4..8ba830a975 100644
--- a/packages/playwright-test/src/reporters/base.ts
+++ b/packages/playwright-test/src/reporters/base.ts
@@ -86,6 +86,11 @@ export class BaseReporter implements Reporter {
}
onTestEnd(test: TestCase, result: TestResult) {
+ // Ignore any tests that are run in parallel.
+ for (let suite: Suite | undefined = test.parent; suite; suite = suite.parent) {
+ if ((suite as any)._parallelMode === 'parallel')
+ return;
+ }
const projectName = test.titlePath()[1];
const relativePath = relativeTestPath(this.config, test);
const fileAndProject = (projectName ? `[${projectName}] › ` : '') + relativePath;
diff --git a/tests/playwright-test/reporter-base.spec.ts b/tests/playwright-test/reporter-base.spec.ts
index 259ee871f2..531ab5eefc 100644
--- a/tests/playwright-test/reporter-base.spec.ts
+++ b/tests/playwright-test/reporter-base.spec.ts
@@ -149,6 +149,30 @@ test('should print slow tests', async ({ runInlineTest }) => {
expect(stripAnsi(result.output)).not.toContain(`Slow test file: [qux] › dir${path.sep}b.test.js (`);
});
+test('should not print slow parallel tests', async ({ runInlineTest }) => {
+ const result = await runInlineTest({
+ 'playwright.config.ts': `
+ module.exports = {
+ reportSlowTests: { max: 0, threshold: 500 },
+ };
+ `,
+ 'dir/a.test.js': `
+ const { test } = pwt;
+ test.describe.parallel('suite', () => {
+ test('inner slow test', async ({}) => {
+ await new Promise(f => setTimeout(f, 1000));
+ });
+ test('inner fast test', async ({}) => {
+ await new Promise(f => setTimeout(f, 100));
+ });
+ });
+ `,
+ });
+ expect(result.exitCode).toBe(0);
+ expect(result.passed).toBe(2);
+ expect(stripAnsi(result.output)).not.toContain('Slow test file');
+});
+
test('should not print slow tests', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `