Skip to content

Commit

Permalink
chore: allow passing path to config to the test server (#30068)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Mar 22, 2024
1 parent ee9432b commit 1539cde
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/playwright/src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions packages/playwright/src/runner/testServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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,
Expand All @@ -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();
Expand Down
7 changes: 5 additions & 2 deletions tests/playwright-test/ui-mode-test-setup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 1539cde

Please sign in to comment.