fix(test-runner): support passing slowMo option (#6991)
Fixes #6984 Reverts #6967
This commit is contained in:
parent
5093e4e804
commit
178489d091
|
|
@ -28,9 +28,10 @@ export const test = _baseTest.extend<PlaywrightTestArgs & PlaywrightTestOptions,
|
||||||
playwright: [ require('../inprocess'), { scope: 'worker' } ],
|
playwright: [ require('../inprocess'), { scope: 'worker' } ],
|
||||||
headless: [ undefined, { scope: 'worker' } ],
|
headless: [ undefined, { scope: 'worker' } ],
|
||||||
channel: [ undefined, { scope: 'worker' } ],
|
channel: [ undefined, { scope: 'worker' } ],
|
||||||
|
slowMo: [ undefined, { scope: 'worker' } ],
|
||||||
launchOptions: [ {}, { scope: 'worker' } ],
|
launchOptions: [ {}, { scope: 'worker' } ],
|
||||||
|
|
||||||
browser: [ async ({ playwright, browserName, headless, channel, launchOptions }, use) => {
|
browser: [ async ({ playwright, browserName, headless, channel, slowMo, launchOptions }, use) => {
|
||||||
if (!['chromium', 'firefox', 'webkit'].includes(browserName))
|
if (!['chromium', 'firefox', 'webkit'].includes(browserName))
|
||||||
throw new Error(`Unexpected browserName "${browserName}", must be one of "chromium", "firefox" or "webkit"`);
|
throw new Error(`Unexpected browserName "${browserName}", must be one of "chromium", "firefox" or "webkit"`);
|
||||||
const options: LaunchOptions = {
|
const options: LaunchOptions = {
|
||||||
|
|
@ -41,6 +42,8 @@ export const test = _baseTest.extend<PlaywrightTestArgs & PlaywrightTestOptions,
|
||||||
options.headless = headless;
|
options.headless = headless;
|
||||||
if (channel !== undefined)
|
if (channel !== undefined)
|
||||||
options.channel = channel;
|
options.channel = channel;
|
||||||
|
if (slowMo !== undefined)
|
||||||
|
options.slowMo = slowMo;
|
||||||
const browser = await playwright[browserName].launch(options);
|
const browser = await playwright[browserName].launch(options);
|
||||||
await use(browser);
|
await use(browser);
|
||||||
await browser.close();
|
await browser.close();
|
||||||
|
|
@ -52,6 +55,7 @@ export const test = _baseTest.extend<PlaywrightTestArgs & PlaywrightTestOptions,
|
||||||
acceptDownloads: undefined,
|
acceptDownloads: undefined,
|
||||||
bypassCSP: undefined,
|
bypassCSP: undefined,
|
||||||
colorScheme: undefined,
|
colorScheme: undefined,
|
||||||
|
reducedMotion: undefined,
|
||||||
deviceScaleFactor: undefined,
|
deviceScaleFactor: undefined,
|
||||||
extraHTTPHeaders: undefined,
|
extraHTTPHeaders: undefined,
|
||||||
geolocation: undefined,
|
geolocation: undefined,
|
||||||
|
|
@ -70,7 +74,7 @@ export const test = _baseTest.extend<PlaywrightTestArgs & PlaywrightTestOptions,
|
||||||
viewport: undefined,
|
viewport: undefined,
|
||||||
contextOptions: {},
|
contextOptions: {},
|
||||||
|
|
||||||
context: async ({ browser, screenshot, trace, video, acceptDownloads, bypassCSP, colorScheme, deviceScaleFactor, extraHTTPHeaders, hasTouch, geolocation, httpCredentials, ignoreHTTPSErrors, isMobile, javaScriptEnabled, locale, offline, permissions, proxy, storageState, viewport, timezoneId, userAgent, contextOptions }, use, testInfo) => {
|
context: async ({ browser, screenshot, trace, video, acceptDownloads, bypassCSP, colorScheme, reducedMotion, deviceScaleFactor, extraHTTPHeaders, hasTouch, geolocation, httpCredentials, ignoreHTTPSErrors, isMobile, javaScriptEnabled, locale, offline, permissions, proxy, storageState, viewport, timezoneId, userAgent, contextOptions }, use, testInfo) => {
|
||||||
testInfo.snapshotSuffix = process.platform;
|
testInfo.snapshotSuffix = process.platform;
|
||||||
if (process.env.PWDEBUG)
|
if (process.env.PWDEBUG)
|
||||||
testInfo.setTimeout(0);
|
testInfo.setTimeout(0);
|
||||||
|
|
@ -87,6 +91,8 @@ export const test = _baseTest.extend<PlaywrightTestArgs & PlaywrightTestOptions,
|
||||||
options.bypassCSP = bypassCSP;
|
options.bypassCSP = bypassCSP;
|
||||||
if (colorScheme !== undefined)
|
if (colorScheme !== undefined)
|
||||||
options.colorScheme = colorScheme;
|
options.colorScheme = colorScheme;
|
||||||
|
if (reducedMotion !== undefined)
|
||||||
|
options.reducedMotion = reducedMotion;
|
||||||
if (deviceScaleFactor !== undefined)
|
if (deviceScaleFactor !== undefined)
|
||||||
options.deviceScaleFactor = deviceScaleFactor;
|
options.deviceScaleFactor = deviceScaleFactor;
|
||||||
if (extraHTTPHeaders !== undefined)
|
if (extraHTTPHeaders !== undefined)
|
||||||
|
|
|
||||||
|
|
@ -529,7 +529,7 @@ test('should create a new worker for worker fixtures', async ({ runInlineTest })
|
||||||
'a.test.ts': `
|
'a.test.ts': `
|
||||||
const { test } = pwt;
|
const { test } = pwt;
|
||||||
test('base test', async ({}, testInfo) => {
|
test('base test', async ({}, testInfo) => {
|
||||||
expect(testInfo.workerIndex).toBe(0);
|
expect(testInfo.workerIndex).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
const test2 = test.extend({
|
const test2 = test.extend({
|
||||||
|
|
@ -539,7 +539,7 @@ test('should create a new worker for worker fixtures', async ({ runInlineTest })
|
||||||
}, { scope: 'worker' }],
|
}, { scope: 'worker' }],
|
||||||
});
|
});
|
||||||
test2('a test', async ({ foo }, testInfo) => {
|
test2('a test', async ({ foo }, testInfo) => {
|
||||||
expect(testInfo.workerIndex).toBe(1);
|
expect(testInfo.workerIndex).toBe(0);
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
'b.test.ts': `
|
'b.test.ts': `
|
||||||
|
|
@ -551,7 +551,7 @@ test('should create a new worker for worker fixtures', async ({ runInlineTest })
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
test2('b test', async ({ bar }, testInfo) => {
|
test2('b test', async ({ bar }, testInfo) => {
|
||||||
expect(testInfo.workerIndex).toBe(0);
|
expect(testInfo.workerIndex).toBe(1);
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
}, { workers: 1 });
|
}, { workers: 1 });
|
||||||
|
|
|
||||||
20
types/test.d.ts
vendored
20
types/test.d.ts
vendored
|
|
@ -882,6 +882,13 @@ type BrowserChannel = Exclude<LaunchOptions['channel'], undefined>;
|
||||||
*/
|
*/
|
||||||
type ColorScheme = Exclude<BrowserContextOptions['colorScheme'], undefined>;
|
type ColorScheme = Exclude<BrowserContextOptions['colorScheme'], undefined>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emulates `'prefers-reduced-motion'` media feature,
|
||||||
|
* supported values are `'reduce'`, `'no-preference'`.
|
||||||
|
* @see BrowserContextOptions
|
||||||
|
*/
|
||||||
|
type ReducedMotion = Exclude<BrowserContextOptions['reducedMotion'], undefined>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object containing additional HTTP headers to be sent with every request. All header values must be strings.
|
* An object containing additional HTTP headers to be sent with every request. All header values must be strings.
|
||||||
* @see BrowserContextOptions
|
* @see BrowserContextOptions
|
||||||
|
|
@ -932,6 +939,13 @@ export type PlaywrightWorkerOptions = {
|
||||||
*/
|
*/
|
||||||
channel: BrowserChannel | undefined;
|
channel: BrowserChannel | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slows down Playwright operations by the specified amount of milliseconds.
|
||||||
|
* Useful so that you can see what is going on.
|
||||||
|
* @see LaunchOptions
|
||||||
|
*/
|
||||||
|
slowMo: number | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options used to launch the browser. Other options above (e.g. `headless`) take priority.
|
* Options used to launch the browser. Other options above (e.g. `headless`) take priority.
|
||||||
* @see LaunchOptions
|
* @see LaunchOptions
|
||||||
|
|
@ -997,6 +1011,12 @@ export type PlaywrightTestOptions = {
|
||||||
*/
|
*/
|
||||||
colorScheme: ColorScheme | undefined;
|
colorScheme: ColorScheme | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`.
|
||||||
|
* @see BrowserContextOptions
|
||||||
|
*/
|
||||||
|
reducedMotion: ReducedMotion | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify device scale factor (can be thought of as dpr). Defaults to `1`.
|
* Specify device scale factor (can be thought of as dpr). Defaults to `1`.
|
||||||
* @see BrowserContextOptions
|
* @see BrowserContextOptions
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue