Skip to content

Commit e5480c7

Browse files
authored
chore: update Playwright config (#807)
1 parent 86bcb37 commit e5480c7

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

tests/playwright/playwright.config.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const config: PlaywrightTestConfig = {
5757
/* Retry on CI only */
5858
retries: process.env.CI ? 2 : 0,
5959
/* Opt out of parallel tests on CI. */
60-
workers: process.env.CI ? 2 : 2,
60+
workers: process.env.CI ? 4 : 4,
6161
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
6262
reporter: [
6363
['list'],
@@ -71,6 +71,7 @@ const config: PlaywrightTestConfig = {
7171
),
7272
},
7373
],
74+
['./slow-tests-reporter.ts'],
7475
],
7576
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
7677
use: {
@@ -94,13 +95,6 @@ const config: PlaywrightTestConfig = {
9495
deviceScaleFactor: 2,
9596
},
9697
},
97-
{
98-
name: 'webkit',
99-
use: {
100-
...devices['Desktop Safari'],
101-
deviceScaleFactor: 2,
102-
},
103-
},
10498
],
10599
};
106100

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import type {Reporter, TestCase, TestResult} from '@playwright/test/reporter';
2+
3+
const DELTA = 5000;
4+
const ONE_SECOND = 1000;
5+
6+
class SlowTestsReporter implements Reporter {
7+
private slowTests: {title: string; duration: number}[] = [];
8+
9+
onTestEnd(test: TestCase, {duration}: TestResult) {
10+
if (duration > DELTA) {
11+
const [_, browser, ...rest] = test.titlePath();
12+
this.slowTests.push({
13+
title: `[${browser}] › ${rest.join(' › ')}`,
14+
duration,
15+
});
16+
}
17+
}
18+
19+
onEnd() {
20+
if (this.slowTests.length > 0) {
21+
console.log('---');
22+
console.log(`Slow tests (duration > ${DELTA}), total ${this.slowTests.length}:`);
23+
24+
const sorted = this.slowTests.sort((a, b) => b.duration - a.duration);
25+
sorted.forEach((test, index) => {
26+
console.log(
27+
`${index + 1}. ${test.title} (${(test.duration / ONE_SECOND).toFixed(1)}s)`,
28+
);
29+
});
30+
}
31+
}
32+
}
33+
34+
export default SlowTestsReporter;

0 commit comments

Comments
 (0)