@@ -148,8 +148,8 @@ function getPlaywrightConfig (playwrightRunner) {
148
148
}
149
149
}
150
150
151
- function getRootDir ( playwrightRunner ) {
152
- const config = getPlaywrightConfig ( playwrightRunner )
151
+ function getRootDir ( playwrightRunner , configArg ) {
152
+ const config = configArg ? configArg . config : getPlaywrightConfig ( playwrightRunner )
153
153
if ( config . rootDir ) {
154
154
return config . rootDir
155
155
}
@@ -162,8 +162,8 @@ function getRootDir (playwrightRunner) {
162
162
return process . cwd ( )
163
163
}
164
164
165
- function getProjectsFromRunner ( runner ) {
166
- const config = getPlaywrightConfig ( runner )
165
+ function getProjectsFromRunner ( runner , configArg ) {
166
+ const config = configArg || getPlaywrightConfig ( runner )
167
167
return config . projects ?. map ( ( project ) => {
168
168
if ( project . project ) {
169
169
return project . project
@@ -509,11 +509,12 @@ function dispatcherHookNew (dispatcherExport, runWrapper) {
509
509
return dispatcherExport
510
510
}
511
511
512
- function runnerHook ( runnerExport , playwrightVersion ) {
513
- shimmer . wrap ( runnerExport . Runner . prototype , 'runAllTests' , runAllTests => async function ( ) {
512
+ function runAllTestsWrapper ( runAllTests , playwrightVersion ) {
513
+ // Config parameter is only available from >=1.55.0
514
+ return async function ( config ) {
514
515
let onDone
515
516
516
- rootDir = getRootDir ( this )
517
+ rootDir = getRootDir ( this , config )
517
518
518
519
const processArgv = process . argv . slice ( 2 ) . join ( ' ' )
519
520
const command = `playwright ${ processArgv } `
@@ -586,7 +587,7 @@ function runnerHook (runnerExport, playwrightVersion) {
586
587
}
587
588
}
588
589
589
- const projects = getProjectsFromRunner ( this )
590
+ const projects = getProjectsFromRunner ( this , config )
590
591
591
592
const shouldSetRetries = isFlakyTestRetriesEnabled &&
592
593
flakyTestRetriesCount > 0 &&
@@ -651,6 +652,23 @@ function runnerHook (runnerExport, playwrightVersion) {
651
652
// TODO: we can trick playwright into thinking the session passed by returning
652
653
// 'passed' here. We might be able to use this for both EFD and Test Management tests.
653
654
return runAllTestsReturn
655
+ }
656
+ }
657
+
658
+ function runnerHook ( runnerExport , playwrightVersion ) {
659
+ shimmer . wrap (
660
+ runnerExport . Runner . prototype ,
661
+ 'runAllTests' ,
662
+ runAllTests => runAllTestsWrapper ( runAllTests , playwrightVersion )
663
+ )
664
+ }
665
+
666
+ function runnerHookNew ( runnerExport , playwrightVersion ) {
667
+ runnerExport = shimmer . wrap ( runnerExport , 'runAllTestsWithConfig' , function ( originalGetter ) {
668
+ const originalFunction = originalGetter . call ( this )
669
+ return function ( ) {
670
+ return runAllTestsWrapper ( originalFunction , playwrightVersion )
671
+ }
654
672
} )
655
673
656
674
return runnerExport
@@ -694,6 +712,12 @@ addHook({
694
712
versions : [ '>=1.38.0' ]
695
713
} , runnerHook )
696
714
715
+ addHook ( {
716
+ name : 'playwright' ,
717
+ file : 'lib/runner/testRunner.js' ,
718
+ versions : [ '>=1.55.0' ]
719
+ } , runnerHookNew )
720
+
697
721
addHook ( {
698
722
name : 'playwright' ,
699
723
file : 'lib/runner/dispatcher.js' ,
0 commit comments