web
web copied to clipboard
[WTR/Playwright] "Error: page.goto:" messages void passed tests in Firefox
This code seems to get called twice:
https://github.com/modernweb-dev/web/blob/245123e1b92fe0d468fc7ae1e25663f52e775bea/packages/test-runner-playwright/src/PlaywrightLauncherPage.ts#L46-L57
I'm working on why, but when it does the second navigation to about:blank fails the first navigation and passed tests are voided.
The dumbest, fastest approach seems to be to add a gate, like so (copied from JS output):
stoppingSession = false;
async stopSession() {
const testCoverage = this.nativeInstrumentationEnabledOnPage
? await this.collectTestCoverage(this.config, this.testFiles)
: undefined;
if (!this.stoppingSession) {
this.stoppingSession = true;
return { testCoverage };
}
// navigate to an empty page to kill any running code on the page, stopping timers and
// breaking a potential endless reload loop
await this.playwrightPage.goto('about:blank');
await this.playwrightContext.close();
return { testCoverage };
}
Further up the line, we could change the isActive call to confirm that URL isn't about:blank, like (maybe, I've not tested this):
isActive(sessionId: string) {
return this.activePages.has(sessionId) && this.activePages.get(sessionId).url !== 'about:blank';
}
OR, maybe we could do something about holding better state all the way up at the TestScheduler.ts level.
Thoughts?