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
chore: allow passing path to config to the test server (#30068)
Pavel Feldman1539cde0343a
diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.tsindex d16a47d4e6..dbae2f693b 100644--- a/packages/playwright/src/program.ts+++ b/packages/playwright/src/program.ts@@ -108,6 +108,7 @@ function addFindRelatedTestFilesCommand(program: Command) {function addTestServerCommand(program: Command) {const command = program.command('test-server', { hidden: true });command.description('start test server');+ command.option('-c, --config <file>', `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);command.option('--host <host>', 'Host to start the server on', 'localhost');command.option('--port <port>', 'Port to start the server on', '0');command.action(opts => runTestServer(opts));diff --git a/packages/playwright/src/runner/testServer.ts b/packages/playwright/src/runner/testServer.tsindex 33cc6e4f9e..d100e04983 100644--- a/packages/playwright/src/runner/testServer.ts+++ b/packages/playwright/src/runner/testServer.ts@@ -24,7 +24,7 @@ import { collectAffectedTestFiles, dependenciesForTestFile } from '../transform/import type { FullConfigInternal } from '../common/config';import { InternalReporter } from '../reporters/internalReporter';import { createReporterForTestServer, createReporters } from './reporters';-import { TestRun, createTaskRunnerForList, createTaskRunnerForWatch, createTaskRunnerForWatchSetup } from './tasks';+import { TestRun, createTaskRunnerForList, createTaskRunnerForTestServer, createTaskRunnerForWatchSetup } from './tasks';import { open } from 'playwright-core/lib/utilsBundle';import ListReporter from '../reporters/list';import { Multiplexer } from '../reporters/multiplexer';@@ -97,7 +97,7 @@ class TestServerDispatcher implements TestServerInterface {this._configFile = configFile;this.transport = {dispatch: (method, params) => (this as any)[method](params),- onclose: () => {},+ onclose: () => gracefullyProcessExitDoNotHang(0),};this._globalWatcher = new Watcher('deep', () => this._dispatchEvent('listChanged', {}));this._testWatcher = new Watcher('flat', events => {@@ -238,7 +238,7 @@ class TestServerDispatcher implements TestServerInterface {timeout: params.timeout,reporter: params.reporters ? params.reporters.map(r => [r]) : undefined,use: {- trace: params.trace === 'on' ? { mode: 'on', sources: false, _live: true } : undefined,+ trace: params.trace === 'on' ? { mode: 'on', sources: false, _live: true } : (params.trace === 'off' ? 'off' : undefined),headless: params.headed ? false : undefined,_optionContextReuseMode: params.reuseContext ? 'when-possible' : undefined,_optionConnectOptions: params.connectWsEndpoint ? { wsEndpoint: params.connectWsEndpoint } : undefined,@@ -263,7 +263,7 @@ class TestServerDispatcher implements TestServerInterface {const reporters = await createReporters(config, 'test', true);reporters.push(await createReporterForTestServer(config, 'test', params.serializer || require.resolve('./uiModeReporter'), e => this._dispatchEvent('report', e)));const reporter = new InternalReporter(new Multiplexer(reporters));- const taskRunner = createTaskRunnerForWatch(config, reporter);+ const taskRunner = createTaskRunnerForTestServer(config, reporter);const testRun = new TestRun(config, reporter);reporter.onConfigure(config.config);const stop = new ManualPromise();diff --git a/tests/playwright-test/ui-mode-test-setup.spec.ts b/tests/playwright-test/ui-mode-test-setup.spec.tsindex 4def43d078..7a5ce3f084 100644--- a/tests/playwright-test/ui-mode-test-setup.spec.ts+++ b/tests/playwright-test/ui-mode-test-setup.spec.ts@@ -50,8 +50,10 @@ test('should run global setup and teardown', async ({ runUITest }) => {]);});-test('should teardown on sigint', async ({ runUITest }) => {+test('should teardown on sigint', async ({ runUITest, nodeVersion }) => {test.skip(process.platform === 'win32', 'No sending SIGINT on Windows');+ test.skip(nodeVersion.major < 18);+const { page, testProcess } = await runUITest({'playwright.config.ts': `import { defineConfig } from '@playwright/test';@@ -201,8 +203,9 @@ test('should run part of the setup only', async ({ runUITest }) => {for (const useWeb of [true, false]) {test.describe(`web-mode: ${useWeb}`, () => {- test('should run teardown with SIGINT', async ({ runUITest }) => {+ test('should run teardown with SIGINT', async ({ runUITest, nodeVersion }) => {test.skip(process.platform === 'win32', 'No sending SIGINT on Windows');+ test.skip(nodeVersion.major < 18);const { page, testProcess } = await runUITest({'playwright.config.ts': `import { defineConfig } from '@playwright/test';