diff --git a/src/test/index.ts b/src/test/index.ts index dec523ecc2..1859a2fda2 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -28,9 +28,10 @@ export const test = _baseTest.extend { + browser: [ async ({ playwright, browserName, headless, channel, slowMo, launchOptions }, use) => { if (!['chromium', 'firefox', 'webkit'].includes(browserName)) throw new Error(`Unexpected browserName "${browserName}", must be one of "chromium", "firefox" or "webkit"`); const options: LaunchOptions = { @@ -41,6 +42,8 @@ export const test = _baseTest.extend { + 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; if (process.env.PWDEBUG) testInfo.setTimeout(0); @@ -87,6 +91,8 @@ export const test = _baseTest.extend { - expect(testInfo.workerIndex).toBe(0); + expect(testInfo.workerIndex).toBe(1); }); const test2 = test.extend({ @@ -539,7 +539,7 @@ test('should create a new worker for worker fixtures', async ({ runInlineTest }) }, { scope: 'worker' }], }); test2('a test', async ({ foo }, testInfo) => { - expect(testInfo.workerIndex).toBe(1); + expect(testInfo.workerIndex).toBe(0); }); `, 'b.test.ts': ` @@ -551,7 +551,7 @@ test('should create a new worker for worker fixtures', async ({ runInlineTest }) }, }); test2('b test', async ({ bar }, testInfo) => { - expect(testInfo.workerIndex).toBe(0); + expect(testInfo.workerIndex).toBe(1); }); `, }, { workers: 1 }); diff --git a/types/test.d.ts b/types/test.d.ts index 47b1276942..10caf7162a 100644 --- a/types/test.d.ts +++ b/types/test.d.ts @@ -882,6 +882,13 @@ type BrowserChannel = Exclude; */ type ColorScheme = Exclude; +/** + * Emulates `'prefers-reduced-motion'` media feature, + * supported values are `'reduce'`, `'no-preference'`. + * @see BrowserContextOptions + */ + type ReducedMotion = Exclude; + /** * An object containing additional HTTP headers to be sent with every request. All header values must be strings. * @see BrowserContextOptions @@ -932,6 +939,13 @@ export type PlaywrightWorkerOptions = { */ 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. * @see LaunchOptions @@ -997,6 +1011,12 @@ export type PlaywrightTestOptions = { */ 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`. * @see BrowserContextOptions