chore: allow passing path to config to the test server (#30068)
This commit is contained in:
parent
ee9432b9da
commit
1539cde034
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Reference in a new issue