Skip to content

Commit efea8ea

Browse files
author
Andy Weiss
committed
Allow for Instanbul coverage with Playwright
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.
1 parent c6773fd commit efea8ea

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.changeset/tidy-knives-agree.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@web/test-runner-playwright': patch
3+
---
4+
5+
Support browser generated coverage without native instrumentation

packages/test-runner-playwright/src/PlaywrightLauncherPage.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ export class PlaywrightLauncherPage {
4444
}
4545

4646
async stopSession(): Promise<SessionResult> {
47-
const testCoverage = this.nativeInstrumentationEnabledOnPage
48-
? await this.collectTestCoverage(this.config, this.testFiles)
49-
: undefined;
47+
const testCoverage = await this.collectTestCoverage(this.config, this.testFiles);
5048

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

83+
if (!this.nativeInstrumentationEnabledOnPage) {
84+
return undefined;
85+
}
86+
8587
// get native coverage from playwright
8688
let coverage: V8Coverage[];
8789
if (this.product === 'chromium') {

0 commit comments

Comments
 (0)