Skip to content

Commit

Permalink
Allow for Instanbul coverage with Playwright
Browse files Browse the repository at this point in the history
This makes the PlaywrightLauncherPage function similarly to the
ChromeLauncher where we attempt to load the coverage from the browser
and return that if availble during the stopSession method. Currently the
Playwright launcher breaks early if the native instrumentation is not
enabled.

We changed to using the Playwright launcher and were suprised that our
coverage stopped working even though we are using the babel istanbul
plugin which worked when we were using the ChromeLauncher.
  • Loading branch information
Andy Weiss committed Aug 9, 2024
1 parent c6773fd commit 0bbf46c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/test-runner-playwright/src/PlaywrightLauncherPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export class PlaywrightLauncherPage {
}

async stopSession(): Promise<SessionResult> {
const testCoverage = this.nativeInstrumentationEnabledOnPage
? await this.collectTestCoverage(this.config, this.testFiles)
: undefined;
const testCoverage = await this.collectTestCoverage(this.config, this.testFiles);

// navigate to an empty page to kill any running code on the page, stopping timers and
// breaking a potential endless reload loop
Expand Down Expand Up @@ -82,6 +80,10 @@ export class PlaywrightLauncherPage {
);
}

if (!this.nativeInstrumentationEnabledOnPage) {
return undefined;
}

// get native coverage from playwright
let coverage: V8Coverage[];
if (this.product === 'chromium') {
Expand Down

0 comments on commit 0bbf46c

Please sign in to comment.