Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix: various test-related fixes (#6916)
Dmitry Gozman69b734629cb3
diff --git a/src/server/supplements/recorderSupplement.ts b/src/server/supplements/recorderSupplement.tsindex ccd040a37c..345d0db221 100644--- a/src/server/supplements/recorderSupplement.ts+++ b/src/server/supplements/recorderSupplement.ts@@ -131,6 +131,7 @@ export class RecorderSupplement implements InstrumentationListener {const recorderApp = await RecorderApp.open(this._context);this._recorderApp = recorderApp;recorderApp.once('close', () => {+ this._debugger.resume(false);this._recorderApp = null;});recorderApp.on('event', (data: EventData) => {@@ -231,7 +232,7 @@ export class RecorderSupplement implements InstrumentationListener {if (!this._currentCallsMetadata.has(metadata))this.onBeforeCall(sdkObject, metadata);}- this._recorderApp!.setPaused(this._debugger.isPaused());+ this._recorderApp?.setPaused(this._debugger.isPaused());this._updateUserSources();this.updateCallLog([...this._currentCallsMetadata.keys()]);}diff --git a/src/utils/stackTrace.ts b/src/utils/stackTrace.tsindex 242ca05835..374e7a667b 100644--- a/src/utils/stackTrace.ts+++ b/src/utils/stackTrace.ts@@ -41,6 +41,7 @@ const PW_LIB_DIRS = ['playwright-chromium','playwright-firefox','playwright-webkit',+ path.join('@playwright', 'test'),].map(packageName => path.sep + path.join(packageName, 'lib'));export function captureStackTrace(): { stack: string, frames: StackFrame[] } {diff --git a/tests/config/default.config.ts b/tests/config/default.config.tsindex 6b0d21b05b..c2d51d1419 100644--- a/tests/config/default.config.ts+++ b/tests/config/default.config.ts@@ -63,7 +63,7 @@ const config: folio.Config<CommonOptions & PlaywrightOptions> = {const browserNames = ['chromium', 'webkit', 'firefox'] as BrowserName[];for (const browserName of browserNames) {const executablePath = getExecutablePath(browserName);- if (executablePath && !process.env.FOLIO_WORKER_INDEX)+ if (executablePath && !process.env.TEST_WORKER_INDEX)console.error(`Using executable at ${executablePath}`);const testIgnore: RegExp[] = browserNames.filter(b => b !== browserName).map(b => new RegExp(b));testIgnore.push(/android/, /electron/);diff --git a/tests/inspector/inspectorTest.ts b/tests/inspector/inspectorTest.tsindex 90968f0185..c9f0192622 100644--- a/tests/inspector/inspectorTest.ts+++ b/tests/inspector/inspectorTest.ts@@ -24,12 +24,13 @@ export { expect } from 'folio';type CLITestArgs = {recorderPageGetter: () => Promise<Page>;+ closeRecorder: () => Promise<void>;openRecorder: () => Promise<Recorder>;runCLI: (args: string[]) => CLIMock;};export const test = contextTest.extend<CLITestArgs>({- recorderPageGetter: async ({ page, context, toImpl, browserName, channel, headless, mode, executablePath }, run, testInfo) => {+ recorderPageGetter: async ({ context, toImpl, mode }, run, testInfo) => {process.env.PWTEST_RECORDER_PORT = String(10907 + testInfo.workerIndex);testInfo.skip(mode === 'service');await run(async () => {@@ -42,6 +43,12 @@ export const test = contextTest.extend<CLITestArgs>({});},+ closeRecorder: async ({ context, toImpl }, run) => {+ await run(async () => {+ await toImpl(context).recorderAppForTest.close();+ });+ },+runCLI: async ({ browserName, channel, headless, mode, executablePath }, run, testInfo) => {process.env.PWTEST_RECORDER_PORT = String(10907 + testInfo.workerIndex);testInfo.skip(mode === 'service');diff --git a/tests/inspector/pause.spec.ts b/tests/inspector/pause.spec.tsindex 09e9191c49..4fda959411 100644--- a/tests/inspector/pause.spec.ts+++ b/tests/inspector/pause.spec.ts@@ -17,6 +17,18 @@import { Page } from '../../index';import { test as it, expect } from './inspectorTest';++it('should resume when closing inspector', async ({page, recorderPageGetter, closeRecorder, mode}) => {+ it.skip(mode !== 'default');++ const scriptPromise = (async () => {+ await page.pause();+ })();+ await recorderPageGetter();+ await closeRecorder();+ await scriptPromise;+});+it.describe('pause', () => {it.skip(({ mode }) => mode !== 'default');diff --git a/tests/launcher.spec.ts b/tests/launcher.spec.tsindex fc267815e7..a33c666bfc 100644--- a/tests/launcher.spec.ts+++ b/tests/launcher.spec.ts@@ -26,6 +26,7 @@ it('should require top-level DeviceDescriptors', async ({playwright}) => {const Devices = require('../lib/server/deviceDescriptors.js');expect(Devices['iPhone 6']).toBeTruthy();expect(Devices['iPhone 6']).toEqual(playwright.devices['iPhone 6']);+ expect(playwright.devices['iPhone 6'].defaultBrowserType).toBe('webkit');});it('should kill browser process on timeout after close', async ({browserType, browserOptions, mode}) => {diff --git a/utils/generate_types/test/test.ts b/utils/generate_types/test/test.tsindex 964456d923..fb08ac3782 100644--- a/utils/generate_types/test/test.ts+++ b/utils/generate_types/test/test.ts@@ -681,8 +681,8 @@ playwright.chromium.launch().then(async browser => {for (const frameLike of frameLikes) {{const handle = await frameLike.waitForSelector('body');- const bodyAssertion: AssertType<playwright.ElementHandle<HTMLBodyElement>, typeof handle> = true;- const canBeNull: AssertCanBeNull<typeof handle> = false+ const bodyAssertion: AssertType<playwright.ElementHandle<HTMLBodyElement>, typeof handle> = true;+ const canBeNull: AssertCanBeNull<typeof handle> = false}{const handle = await frameLike.waitForSelector('body', {timeout: 0});@@ -714,8 +714,8 @@ playwright.chromium.launch().then(async browser => {{const handle = await frameLike.waitForSelector('something-strange', {timeout: 0});const elementAssertion: AssertType<playwright.ElementHandle<HTMLElement|SVGElement>, typeof handle> = true;- const canBeNull: AssertCanBeNull<typeof handle> = false;- }+ const canBeNull: AssertCanBeNull<typeof handle> = false;+ }{const state = Math.random() > .5 ? 'attached' : 'visible';const handle = await frameLike.waitForSelector('something-strange', {state});