File tree Expand file tree Collapse file tree 2 files changed +36
-8
lines changed Expand file tree Collapse file tree 2 files changed +36
-8
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments