@@ -11,6 +11,7 @@ export class PlaywrightLauncherPage {
1111 public playwrightContext : BrowserContext ;
1212 public playwrightPage : Page ;
1313 private nativeInstrumentationEnabledOnPage = false ;
14+ private collectCoverage = false ;
1415
1516 constructor (
1617 config : TestRunnerCoreConfig ,
@@ -27,6 +28,8 @@ export class PlaywrightLauncherPage {
2728 }
2829
2930 async runSession ( url : string , coverage : boolean ) {
31+ this . collectCoverage = coverage ;
32+
3033 if (
3134 coverage &&
3235 this . product === 'chromium' &&
@@ -44,7 +47,7 @@ export class PlaywrightLauncherPage {
4447 }
4548
4649 async stopSession ( ) : Promise < SessionResult > {
47- const testCoverage = this . nativeInstrumentationEnabledOnPage
50+ const testCoverage = this . collectCoverage
4851 ? await this . collectTestCoverage ( this . config , this . testFiles )
4952 : undefined ;
5053
@@ -77,8 +80,8 @@ export class PlaywrightLauncherPage {
7780 if ( config . coverageConfig ?. nativeInstrumentation === false ) {
7881 throw new Error (
7982 'Coverage is enabled with nativeInstrumentation disabled. ' +
80- 'Expected coverage provided in the browser as a global __coverage__ variable.' +
81- 'Use a plugin like babel-plugin-istanbul to generate the coverage, or enable native instrumentation.' ,
83+ 'Expected coverage provided in the browser as a global __coverage__ variable.' +
84+ 'Use a plugin like babel-plugin-istanbul to generate the coverage, or enable native instrumentation.' ,
8285 ) ;
8386 }
8487
0 commit comments