fix: various test-related fixes (#6916)
- Closing inspector window resumes the script. - Replace FOLIO_WORKER_INDEX with TEST_WORKER_INDEX. - Account for `@playwright/test` stack traces.
This commit is contained in:
parent
a83646684a
commit
69b734629c
|
|
@ -131,6 +131,7 @@ export class RecorderSupplement implements InstrumentationListener {
|
||||||
const recorderApp = await RecorderApp.open(this._context);
|
const recorderApp = await RecorderApp.open(this._context);
|
||||||
this._recorderApp = recorderApp;
|
this._recorderApp = recorderApp;
|
||||||
recorderApp.once('close', () => {
|
recorderApp.once('close', () => {
|
||||||
|
this._debugger.resume(false);
|
||||||
this._recorderApp = null;
|
this._recorderApp = null;
|
||||||
});
|
});
|
||||||
recorderApp.on('event', (data: EventData) => {
|
recorderApp.on('event', (data: EventData) => {
|
||||||
|
|
@ -231,7 +232,7 @@ export class RecorderSupplement implements InstrumentationListener {
|
||||||
if (!this._currentCallsMetadata.has(metadata))
|
if (!this._currentCallsMetadata.has(metadata))
|
||||||
this.onBeforeCall(sdkObject, metadata);
|
this.onBeforeCall(sdkObject, metadata);
|
||||||
}
|
}
|
||||||
this._recorderApp!.setPaused(this._debugger.isPaused());
|
this._recorderApp?.setPaused(this._debugger.isPaused());
|
||||||
this._updateUserSources();
|
this._updateUserSources();
|
||||||
this.updateCallLog([...this._currentCallsMetadata.keys()]);
|
this.updateCallLog([...this._currentCallsMetadata.keys()]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ const PW_LIB_DIRS = [
|
||||||
'playwright-chromium',
|
'playwright-chromium',
|
||||||
'playwright-firefox',
|
'playwright-firefox',
|
||||||
'playwright-webkit',
|
'playwright-webkit',
|
||||||
|
path.join('@playwright', 'test'),
|
||||||
].map(packageName => path.sep + path.join(packageName, 'lib'));
|
].map(packageName => path.sep + path.join(packageName, 'lib'));
|
||||||
|
|
||||||
export function captureStackTrace(): { stack: string, frames: StackFrame[] } {
|
export function captureStackTrace(): { stack: string, frames: StackFrame[] } {
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ const config: folio.Config<CommonOptions & PlaywrightOptions> = {
|
||||||
const browserNames = ['chromium', 'webkit', 'firefox'] as BrowserName[];
|
const browserNames = ['chromium', 'webkit', 'firefox'] as BrowserName[];
|
||||||
for (const browserName of browserNames) {
|
for (const browserName of browserNames) {
|
||||||
const executablePath = getExecutablePath(browserName);
|
const executablePath = getExecutablePath(browserName);
|
||||||
if (executablePath && !process.env.FOLIO_WORKER_INDEX)
|
if (executablePath && !process.env.TEST_WORKER_INDEX)
|
||||||
console.error(`Using executable at ${executablePath}`);
|
console.error(`Using executable at ${executablePath}`);
|
||||||
const testIgnore: RegExp[] = browserNames.filter(b => b !== browserName).map(b => new RegExp(b));
|
const testIgnore: RegExp[] = browserNames.filter(b => b !== browserName).map(b => new RegExp(b));
|
||||||
testIgnore.push(/android/, /electron/);
|
testIgnore.push(/android/, /electron/);
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,13 @@ export { expect } from 'folio';
|
||||||
|
|
||||||
type CLITestArgs = {
|
type CLITestArgs = {
|
||||||
recorderPageGetter: () => Promise<Page>;
|
recorderPageGetter: () => Promise<Page>;
|
||||||
|
closeRecorder: () => Promise<void>;
|
||||||
openRecorder: () => Promise<Recorder>;
|
openRecorder: () => Promise<Recorder>;
|
||||||
runCLI: (args: string[]) => CLIMock;
|
runCLI: (args: string[]) => CLIMock;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const test = contextTest.extend<CLITestArgs>({
|
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);
|
process.env.PWTEST_RECORDER_PORT = String(10907 + testInfo.workerIndex);
|
||||||
testInfo.skip(mode === 'service');
|
testInfo.skip(mode === 'service');
|
||||||
await run(async () => {
|
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) => {
|
runCLI: async ({ browserName, channel, headless, mode, executablePath }, run, testInfo) => {
|
||||||
process.env.PWTEST_RECORDER_PORT = String(10907 + testInfo.workerIndex);
|
process.env.PWTEST_RECORDER_PORT = String(10907 + testInfo.workerIndex);
|
||||||
testInfo.skip(mode === 'service');
|
testInfo.skip(mode === 'service');
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,18 @@
|
||||||
import { Page } from '../../index';
|
import { Page } from '../../index';
|
||||||
import { test as it, expect } from './inspectorTest';
|
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.describe('pause', () => {
|
||||||
it.skip(({ mode }) => mode !== 'default');
|
it.skip(({ mode }) => mode !== 'default');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ it('should require top-level DeviceDescriptors', async ({playwright}) => {
|
||||||
const Devices = require('../lib/server/deviceDescriptors.js');
|
const Devices = require('../lib/server/deviceDescriptors.js');
|
||||||
expect(Devices['iPhone 6']).toBeTruthy();
|
expect(Devices['iPhone 6']).toBeTruthy();
|
||||||
expect(Devices['iPhone 6']).toEqual(playwright.devices['iPhone 6']);
|
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}) => {
|
it('should kill browser process on timeout after close', async ({browserType, browserOptions, mode}) => {
|
||||||
|
|
|
||||||
|
|
@ -681,8 +681,8 @@ playwright.chromium.launch().then(async browser => {
|
||||||
for (const frameLike of frameLikes) {
|
for (const frameLike of frameLikes) {
|
||||||
{
|
{
|
||||||
const handle = await frameLike.waitForSelector('body');
|
const handle = await frameLike.waitForSelector('body');
|
||||||
const bodyAssertion: AssertType<playwright.ElementHandle<HTMLBodyElement>, typeof handle> = true;
|
const bodyAssertion: AssertType<playwright.ElementHandle<HTMLBodyElement>, typeof handle> = true;
|
||||||
const canBeNull: AssertCanBeNull<typeof handle> = false
|
const canBeNull: AssertCanBeNull<typeof handle> = false
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const handle = await frameLike.waitForSelector('body', {timeout: 0});
|
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 handle = await frameLike.waitForSelector('something-strange', {timeout: 0});
|
||||||
const elementAssertion: AssertType<playwright.ElementHandle<HTMLElement|SVGElement>, typeof handle> = true;
|
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 state = Math.random() > .5 ? 'attached' : 'visible';
|
||||||
const handle = await frameLike.waitForSelector('something-strange', {state});
|
const handle = await frameLike.waitForSelector('something-strange', {state});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue