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
test: allow startRemoteServer and launchPersistent only in default mode (#38090)
Yury Semikhatsky719f756be196
diff --git a/tests/config/browserTest.ts b/tests/config/browserTest.tsindex 2fe17120e9..2279e01197 100644--- a/tests/config/browserTest.ts+++ b/tests/config/browserTest.ts@@ -128,7 +128,9 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>await removeFolders(dirs);},- launchPersistent: async ({ createUserDataDir, browserType }, run) => {+ launchPersistent: async ({ createUserDataDir, browserType, mode }, run) => {+ test.skip(mode !== 'default', 'Remote persistent contexts are not supported');+let persistentContext: BrowserContext | undefined;await run(async options => {if (persistentContext)@@ -142,7 +144,9 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>await persistentContext.close();},- startRemoteServer: async ({ childProcess, browserType, channel }, run) => {+ startRemoteServer: async ({ childProcess, browserType, channel, mode }, run) => {+ test.skip(mode !== 'default', 'Starting remote server is not supported in remote modes');+let server: PlaywrightServer | undefined;const fn = async (kind: 'launchServer' | 'run-server', options?: RemoteServerOptions) => {if (server)diff --git a/tests/library/browsertype-connect.spec.ts b/tests/library/browsertype-connect.spec.tsindex f92d46546a..acd5367677 100644--- a/tests/library/browsertype-connect.spec.ts+++ b/tests/library/browsertype-connect.spec.ts@@ -72,14 +72,11 @@ const test = playwrightTest.extend<ExtraFixtures>({});test.slow(true, 'All connect tests are slow');-test.skip(({ mode }) => mode.startsWith('service'));-test.skip(({ mode }) => mode === 'wsl');for (const kind of ['launchServer', 'run-server'] as const) {test.describe(kind, () => {- test('should connect over wss', async ({ connect, startRemoteServer, httpsServer, mode }) => {- test.skip(mode !== 'default'); // Out of process transport does not allow us to set env vars dynamically.+ test('should connect over wss', async ({ connect, startRemoteServer, httpsServer }) => {const remoteServer = await startRemoteServer(kind);const oldValue = process.env['NODE_TLS_REJECT_UNAUTHORIZED'];@@ -314,9 +311,7 @@ for (const kind of ['launchServer', 'run-server'] as const) {expect(disconnected).toBe(browser);});- test('should handle exceptions during connect', async ({ connect, startRemoteServer, mode }) => {- test.skip(mode !== 'default');-+ test('should handle exceptions during connect', async ({ connect, startRemoteServer }) => {const remoteServer = await startRemoteServer(kind);const __testHookBeforeCreateBrowser = () => { throw new Error('Dummy'); };const error = await connect(remoteServer.wsEndpoint(), { __testHookBeforeCreateBrowser } as any).catch(e => e);@@ -687,8 +682,7 @@ for (const kind of ['launchServer', 'run-server'] as const) {expect(await response.json()).toEqual({ 'foo': 'bar' });});- test('should upload large file', async ({ connect, startRemoteServer, server, mode }, testInfo) => {- test.skip(mode.startsWith('service'), 'Take it easy on service');+ test('should upload large file', async ({ connect, startRemoteServer, server }, testInfo) => {test.slow();const remoteServer = await startRemoteServer(kind);const browser = await connect(remoteServer.wsEndpoint());@@ -759,8 +753,7 @@ for (const kind of ['launchServer', 'run-server'] as const) {expect(Math.abs(timestamps[i] - expectedTimestamps[i]), `expected: ${expectedTimestamps}; actual: ${timestamps}`).toBeLessThan(1000);});- test('should connect over http', async ({ connect, startRemoteServer, mode }) => {- test.skip(mode !== 'default');+ test('should connect over http', async ({ connect, startRemoteServer }) => {const remoteServer = await startRemoteServer(kind);const url = new URL(remoteServer.wsEndpoint());@@ -770,7 +763,6 @@ for (const kind of ['launchServer', 'run-server'] as const) {});test.describe('socks proxy', () => {- test.skip(({ mode }) => mode !== 'default');test.skip(kind === 'launchServer', 'not supported yet');test('should forward non-forwarded requests', async ({ server, startRemoteServer, connect }) => {@@ -971,7 +963,7 @@ for (const kind of ['launchServer', 'run-server'] as const) {expect(failed).toBe(true);});- test('should check proxy pattern on the client', async ({ connect, startRemoteServer, server, browserName, platform, dummyServerPort }, workerInfo) => {+ test('should check proxy pattern on the client', async ({ connect, startRemoteServer, server, dummyServerPort }) => {let reachedOriginalTarget = false;server.setRoute('/foo.html', async (req, res) => {reachedOriginalTarget = true;diff --git a/tests/library/defaultbrowsercontext-2.spec.ts b/tests/library/defaultbrowsercontext-2.spec.tsindex 16db4880da..32ed2129b8 100644--- a/tests/library/defaultbrowsercontext-2.spec.ts+++ b/tests/library/defaultbrowsercontext-2.spec.ts@@ -19,6 +19,8 @@ import { playwrightTest as it, expect } from '../config/browserTest';import fs from 'fs';import path from 'path';+it.skip(({ mode }) => mode !== 'default', 'Remote persistent contexts are not supported');+it('should support hasTouch option', async ({ server, launchPersistent }) => {const { page } = await launchPersistent({ hasTouch: true });await page.goto(server.PREFIX + '/mobile.html');@@ -108,7 +110,7 @@ it('should accept relative userDataDir', async ({ createUserDataDir, browserTypeawait context.close();});-it('should restore state from userDataDir', async ({ browserType, server, createUserDataDir, isMac, browserName }) => {+it('should restore state from userDataDir', async ({ browserType, server, createUserDataDir }) => {it.slow();const userDataDir = await createUserDataDir();@@ -156,9 +158,7 @@ it('should throw if page argument is passed', async ({ browserType, server, creaexpect(error.message).toContain('can not specify page');});-it('should have passed URL when launching with ignoreDefaultArgs: true', async ({ browserType, server, createUserDataDir, toImpl, mode, browserName }) => {- it.skip(mode !== 'default');-+it('should have passed URL when launching with ignoreDefaultArgs: true', async ({ browserType, server, createUserDataDir, toImpl, browserName }) => {const userDataDir = await createUserDataDir();const args = (await toImpl(browserType).defaultArgs((browserType as any)._playwright._defaultLaunchOptions, 'persistent', userDataDir, 0)).filter(a => a !== 'about:blank');const options = {@@ -174,17 +174,13 @@ it('should have passed URL when launching with ignoreDefaultArgs: true', async (await browserContext.close();});-it('should handle timeout', async ({ browserType, createUserDataDir, mode }) => {- it.skip(mode !== 'default');-+it('should handle timeout', async ({ browserType, createUserDataDir }) => {const options: any = { timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) };const error = await browserType.launchPersistentContext(await createUserDataDir(), options).catch(e => e);expect(error.message).toContain(`browserType.launchPersistentContext: Timeout 5000ms exceeded.`);});-it('should handle exception', async ({ browserType, createUserDataDir, mode }) => {- it.skip(mode !== 'default');-+it('should handle exception', async ({ browserType, createUserDataDir }) => {const e = new Error('Dummy');const options: any = { __testHookBeforeCreateBrowser: () => { throw e; } };const error = await browserType.launchPersistentContext(await createUserDataDir(), options).catch(e => e);@@ -228,9 +224,7 @@ it('should respect selectors', async ({ playwright, launchPersistent }) => {expect(await page.innerHTML('defaultContextCSS=div')).toBe('hello');});-it('should connect to a browser with the default page', async ({ browserType, createUserDataDir, mode }) => {- it.skip(mode !== 'default');-+it('should connect to a browser with the default page', async ({ browserType, createUserDataDir }) => {const options: any = { __testHookOnConnectToBrowser: () => new Promise(f => setTimeout(f, 3000)) };const context = await browserType.launchPersistentContext(await createUserDataDir(), options);expect(context.pages().length).toBe(1);@@ -248,8 +242,7 @@ it('should support har option', async ({ launchPersistent, asset }) => {await expect(page.locator('body')).toHaveCSS('background-color', 'rgb(255, 0, 0)');});-it('user agent is up to date', async ({ launchPersistent, browser, mode }) => {- it.skip(mode !== 'default');+it('user agent is up to date', async ({ launchPersistent, browser }) => {const { userAgent } = await (browser as any)._channel.defaultUserAgentForTest();const { context, page } = await launchPersistent();expect(await page.evaluate(() => navigator.userAgent)).toBe(userAgent);@@ -258,8 +251,7 @@ it('user agent is up to date', async ({ launchPersistent, browser, mode }) => {it('dialog.accept should work', {annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/35663' }-}, async ({ launchPersistent, mode }) => {- it.skip(mode !== 'default');+}, async ({ launchPersistent }) => {const { context, page } = await launchPersistent();await page.goto('data:text/html,<html><title>Title</title><button onclick="alert(\'Alert\')">Button</button></html>');let shown = false;