Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: cleanup test root folder (#40100)

Pavel Feldman783b664fc7a9
diff --git a/packages/playwright-ct-core/src/DEPS.list b/packages/playwright-ct-core/src/DEPS.list
index 76c2d71bd6..ef95f39088 100644
--- a/packages/playwright-ct-core/src/DEPS.list
+++ b/packages/playwright-ct-core/src/DEPS.list
@@ -4,9 +4,6 @@ generated/indexSource.ts
[viteDevPlugin.ts]
generated/indexSource.ts
-[devServer.ts]
-generated/indexSource.ts
-
[mount.ts]
generated/serializers.ts
injected/**
diff --git a/packages/playwright-ct-core/src/devServer.ts b/packages/playwright-ct-core/src/devServer.ts
deleted file mode 100644
index c715f585a1..0000000000
--- a/packages/playwright-ct-core/src/devServer.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import fs from 'fs';
-import path from 'path';
-
-import { Watcher } from 'playwright/lib/fsWatcher';
-import { colors } from 'playwright-core/lib/utilsBundle';
-
-import { source as injectedSource } from './generated/indexSource';
-import { createConfig, frameworkConfig, populateComponentsFromTests, resolveDirs, transformIndexFile } from './viteUtils';
-
-import type { ComponentRegistry } from './viteUtils';
-import type { FullConfig } from 'playwright/test';
-import type { PluginContext } from 'rollup';
-
-export async function runDevServer(config: FullConfig): Promise<() => Promise<void>> {
- const { registerSourceFile, frameworkPluginFactory } = frameworkConfig(config);
- const componentRegistry: ComponentRegistry = new Map();
- await populateComponentsFromTests(componentRegistry);
-
- const configDir = config.configFile ? path.dirname(config.configFile) : config.rootDir;
- const dirs = await resolveDirs(configDir, config);
- if (!dirs) {
- // eslint-disable-next-line no-console
- console.log(colors.red(`Component testing template file playwright/index.html is missing and there is no existing Vite server. Component tests will fail.\n`));
- return async () => {};
- }
- const registerSource = injectedSource + '\n' + await fs.promises.readFile(registerSourceFile, 'utf-8');
- const viteConfig = await createConfig(dirs, config, frameworkPluginFactory, false);
- viteConfig.plugins.push({
- name: 'playwright:component-index',
-
- async transform(this: PluginContext, content: string, id: string) {
- return transformIndexFile(id, content, dirs.templateDir, registerSource, componentRegistry);
- },
- });
-
- const { createServer } = await import('vite');
- const devServer = await createServer(viteConfig);
- await devServer.listen();
- const protocol = viteConfig.server.https ? 'https:' : 'http:';
- // eslint-disable-next-line no-console
- console.log(`Dev Server listening on ${protocol}//${viteConfig.server.host || 'localhost'}:${viteConfig.server.port}`);
-
- const projectDirs = new Set<string>();
- const projectOutputs = new Set<string>();
- for (const p of config.projects) {
- projectDirs.add(p.testDir);
- projectOutputs.add(p.outputDir);
- }
-
- const globalWatcher = new Watcher(async () => {
- const registry: ComponentRegistry = new Map();
- await populateComponentsFromTests(registry);
- // compare componentRegistry to registry key sets.
- if (componentRegistry.size === registry.size && [...componentRegistry.keys()].every(k => registry.has(k)))
- return;
-
- // eslint-disable-next-line no-console
- console.log('List of components changed');
- componentRegistry.clear();
- for (const [k, v] of registry)
- componentRegistry.set(k, v);
-
- const id = path.join(dirs.templateDir, 'index');
- const modules = [...devServer.moduleGraph.urlToModuleMap.values()];
- const rootModule = modules.find(m => m.file?.startsWith(id + '.ts') || m.file?.startsWith(id + '.js'));
- if (rootModule)
- devServer.moduleGraph.onFileChange(rootModule.file!);
- });
- await globalWatcher.update([...projectDirs], [...projectOutputs], false);
- return () => Promise.all([devServer.close(), globalWatcher.close()]).then(() => {});
-}
diff --git a/packages/playwright-ct-core/src/vitePlugin.ts b/packages/playwright-ct-core/src/vitePlugin.ts
index 9a8912b75c..f0facbbf9a 100644
--- a/packages/playwright-ct-core/src/vitePlugin.ts
+++ b/packages/playwright-ct-core/src/vitePlugin.ts
@@ -24,9 +24,8 @@ import { resolveHook } from 'playwright/lib/transform/transform';
import { removeDirAndLogToConsole } from 'playwright/lib/util';
import { stoppable } from 'playwright/lib/utilsBundle';
-import { runDevServer } from './devServer';
import { source as injectedSource } from './generated/indexSource';
-import { createConfig, frameworkConfig, hasJSComponents, populateComponentsFromTests, resolveDirs, resolveEndpoint, transformIndexFile } from './viteUtils';
+import { createConfig, frameworkConfig, hasJSComponents, populateComponentsFromTests, resolveDirs, transformIndexFile } from './viteUtils';
import type http from 'http';
import type { AddressInfo } from 'net';
@@ -80,10 +79,6 @@ export function createPlugin(): TestRunnerPlugin {
await buildBundle(config, configDir);
},
- startDevServer: async () => {
- return await runDevServer(config);
- },
-
clearCache: async () => {
const configDir = config.configFile ? path.dirname(config.configFile) : config.rootDir;
const dirs = await resolveDirs(configDir, config);
@@ -110,19 +105,6 @@ type BuildInfo = {
export async function buildBundle(config: FullConfig, configDir: string): Promise<{ buildInfo: BuildInfo, viteConfig: Record<string, any> } | null> {
const { registerSourceFile, frameworkPluginFactory } = frameworkConfig(config);
- {
- // Detect a running dev server and use it if available.
- const endpoint = resolveEndpoint(config);
- const protocol = endpoint.https ? 'https:' : 'http:';
- const url = new URL(`${protocol}//${endpoint.host}:${endpoint.port}`);
- if (await serverUtils.isURLAvailable(url, true)) {
- // eslint-disable-next-line no-console
- console.log(`Dev Server is already running at ${url.toString()}, using it.\n`);
- process.env.PLAYWRIGHT_TEST_BASE_URL = url.toString();
- return null;
- }
- }
-
const dirs = await resolveDirs(configDir, config);
if (!dirs) {
// eslint-disable-next-line no-console
diff --git a/packages/playwright/package.json b/packages/playwright/package.json
index 576d64467e..f34e60af14 100644
--- a/packages/playwright/package.json
+++ b/packages/playwright/package.json
@@ -29,7 +29,6 @@
"./lib/transform/compilationCache": "./lib/transform/compilationCache.js",
"./lib/transform/esmLoader": "./lib/transform/esmLoader.js",
"./lib/transform/transform": "./lib/transform/transform.js",
- "./lib/internalsForTest": "./lib/internalsForTest.js",
"./lib/plugins": "./lib/plugins/index.js",
"./lib/runner/testRunner": "./lib/runner/testRunner.js",
"./jsx-runtime": {
diff --git a/packages/playwright/src/DEPS.list b/packages/playwright/src/DEPS.list
index 829803ab70..6d3615f364 100644
--- a/packages/playwright/src/DEPS.list
+++ b/packages/playwright/src/DEPS.list
@@ -23,7 +23,4 @@ common/
./mcp/test/
./transform/babelBundle.ts
-[internalsForTest.ts]
-**
-
[errorContext.ts]
diff --git a/packages/playwright/src/cli/DEPS.list b/packages/playwright/src/cli/DEPS.list
new file mode 100644
index 0000000000..e31a5e6302
--- /dev/null
+++ b/packages/playwright/src/cli/DEPS.list
@@ -0,0 +1,5 @@
+[*]
+../runner/
+../reporters/
+@serverUtils/**
+../common/
diff --git a/packages/playwright/src/reportActions.ts b/packages/playwright/src/cli/reportActions.ts
similarity index 89%
rename from packages/playwright/src/reportActions.ts
rename to packages/playwright/src/cli/reportActions.ts
index 0df0a1ad86..ab0a7667aa 100644
--- a/packages/playwright/src/reportActions.ts
+++ b/packages/playwright/src/cli/reportActions.ts
@@ -18,12 +18,12 @@ import fs from 'fs';
import path from 'path';
import { gracefullyProcessExitDoNotHang } from '@serverUtils/processLauncher';
-import { builtInReporters, defaultReporter } from './common/config';
-import { loadConfigFromFile, loadEmptyConfigForMergeReports } from './common/configLoader';
-import { showHTMLReport } from './reporters/html';
-import { createMergedReport } from './reporters/merge';
+import { builtInReporters, defaultReporter } from '../common/config';
+import { loadConfigFromFile, loadEmptyConfigForMergeReports } from '../common/configLoader';
+import { showHTMLReport } from '../reporters/html';
+import { createMergedReport } from '../reporters/merge';
-import type { ReporterDescription } from '../types/test';
+import type { ReporterDescription } from '../../types/test';
export async function showReport(report: string | undefined, host: string, port: number) {
await showHTMLReport(report, host, port);
diff --git a/packages/playwright/src/testActions.ts b/packages/playwright/src/cli/testActions.ts
similarity index 90%
rename from packages/playwright/src/testActions.ts
rename to packages/playwright/src/cli/testActions.ts
index 003ecb6021..9694fa0ac6 100644
--- a/packages/playwright/src/testActions.ts
+++ b/packages/playwright/src/cli/testActions.ts
@@ -20,17 +20,17 @@ import path from 'path';
import { gracefullyProcessExitDoNotHang } from '@serverUtils/processLauncher';
import { startProfiling, stopProfiling } from '@serverUtils/profiler';
-import { builtInReporters } from './common/config';
-import { loadConfigFromFile, resolveConfigLocation } from './common/configLoader';
-import { terminalScreen } from './reporters/base';
-import { filterProjects } from './runner/projectUtils';
-import * as testServer from './runner/testServer';
-import { runWatchModeLoop } from './runner/watchMode';
-import { runAllTestsWithConfig, TestRunner } from './runner/testRunner';
-import { createErrorCollectingReporter } from './runner/reporters';
-
-import type { ConfigCLIOverrides } from './common/ipc';
-import type { ReporterDescription } from '../types/test';
+import { builtInReporters } from '../common/config';
+import { loadConfigFromFile, resolveConfigLocation } from '../common/configLoader';
+import { terminalScreen } from '../reporters/base';
+import { filterProjects } from '../runner/projectUtils';
+import * as testServer from '../runner/testServer';
+import { runWatchModeLoop } from '../runner/watchMode';
+import { runAllTestsWithConfig, TestRunner } from '../runner/testRunner';
+import { createErrorCollectingReporter } from '../runner/reporters';
+
+import type { ConfigCLIOverrides } from '../common/ipc';
+import type { ReporterDescription } from '../../types/test';
export async function runTests(args: string[], opts: { [key: string]: any }) {
await startProfiling();
@@ -109,11 +109,6 @@ export async function clearCache(opts: { [key: string]: any }) {
gracefullyProcessExitDoNotHang(exitCode);
}
-export async function startDevServer(options: { [key: string]: any }) {
- const runner = new TestRunner(resolveConfigLocation(options.config), {});
- await runner.startDevServer(createErrorCollectingReporter(terminalScreen), 'in-process');
-}
-
function overridesFromOptions(options: { [key: string]: any }): ConfigCLIOverrides {
if (options.ui) {
options.debug = undefined;
diff --git a/packages/playwright/src/internalsForTest.ts b/packages/playwright/src/internalsForTest.ts
deleted file mode 100644
index 129f9e858d..0000000000
--- a/packages/playwright/src/internalsForTest.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import path from 'path';
-
-import { fileDependenciesForTest } from './transform/compilationCache';
-
-export function fileDependencies() {
- return Object.fromEntries([...fileDependenciesForTest().entries()].map(entry => (
- [path.basename(entry[0]), [...entry[1]].map(f => path.basename(f)).sort()]
- )));
-}
diff --git a/packages/playwright/src/isomorphic/testServerConnection.ts b/packages/playwright/src/isomorphic/testServerConnection.ts
index e87c0119b5..2c222b32be 100644
--- a/packages/playwright/src/isomorphic/testServerConnection.ts
+++ b/packages/playwright/src/isomorphic/testServerConnection.ts
@@ -215,14 +215,6 @@ export class TestServerConnection implements TestServerInterface, TestServerInte
return await this._sendMessage('runGlobalTeardown', params);
}
- async startDevServer(params: Parameters<TestServerInterface['startDevServer']>[0]): ReturnType<TestServerInterface['startDevServer']> {
- return await this._sendMessage('startDevServer', params);
- }
-
- async stopDevServer(params: Parameters<TestServerInterface['stopDevServer']>[0]): ReturnType<TestServerInterface['stopDevServer']> {
- return await this._sendMessage('stopDevServer', params);
- }
-
async clearCache(params: Parameters<TestServerInterface['clearCache']>[0]): ReturnType<TestServerInterface['clearCache']> {
return await this._sendMessage('clearCache', params);
}
diff --git a/packages/playwright/src/isomorphic/testServerInterface.ts b/packages/playwright/src/isomorphic/testServerInterface.ts
index c0c91ca9b4..5ac8e022d2 100644
--- a/packages/playwright/src/isomorphic/testServerInterface.ts
+++ b/packages/playwright/src/isomorphic/testServerInterface.ts
@@ -56,16 +56,6 @@ export interface TestServerInterface {
status: reporterTypes.FullResult['status']
}>;
- startDevServer(params: {}): Promise<{
- report: ReportEntry[];
- status: reporterTypes.FullResult['status']
- }>;
-
- stopDevServer(params: {}): Promise<{
- report: ReportEntry[];
- status: reporterTypes.FullResult['status']
- }>;
-
clearCache(params: {}): Promise<void>;
listFiles(params: {
diff --git a/packages/playwright/src/plugins/index.ts b/packages/playwright/src/plugins/index.ts
index 7734145468..4f2e878a4b 100644
--- a/packages/playwright/src/plugins/index.ts
+++ b/packages/playwright/src/plugins/index.ts
@@ -21,7 +21,6 @@ export interface TestRunnerPlugin {
name: string;
setup?(config: FullConfig, configDir: string, reporter: ReporterV2): Promise<void>;
populateDependencies?(): Promise<void>;
- startDevServer?(): Promise<() => Promise<void>>;
clearCache?(): Promise<void>;
begin?(suite: Suite): Promise<void>;
end?(): Promise<void>;
@@ -31,7 +30,6 @@ export interface TestRunnerPlugin {
export type TestRunnerPluginRegistration = {
factory: TestRunnerPlugin | (() => TestRunnerPlugin | Promise<TestRunnerPlugin>);
instance?: TestRunnerPlugin;
- devServerCleanup?: any;
};
export { webServer } from './webServerPlugin';
diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.ts
index 887e55d3cd..e212cb165b 100644
--- a/packages/playwright/src/program.ts
+++ b/packages/playwright/src/program.ts
@@ -23,11 +23,8 @@ import { program } from 'playwright-core/lib/utilsBundle';
import { gracefullyProcessExitDoNotHang } from '@serverUtils/processLauncher';
import { builtInReporters, defaultReporter, defaultTimeout } from './common/config';
-import { runTests } from './testActions';
-import { clearCache } from './testActions';
-import { startDevServer } from './testActions';
-import { runTestServerAction } from './testActions';
-import { showReport, mergeReports } from './reportActions';
+import { runTests, clearCache, runTestServerAction } from './cli/testActions';
+import { showReport, mergeReports } from './cli/reportActions';
import { TestServerBackend, testServerBackendTools } from './mcp/test/testBackend';
import { loadConfigFromFile } from './common/configLoader';
import { ClaudeGenerator, OpencodeGenerator, VSCodeGenerator, CopilotGenerator } from './agents/generateAgents';
@@ -84,15 +81,6 @@ function addClearCacheCommand(program: Command) {
});
}
-function addDevServerCommand(program: Command) {
- const command = program.command('dev-server', { hidden: true });
- command.description('start dev server');
- command.option('-c, --config <file>', `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);
- command.action(async options => {
- await startDevServer(options);
- });
-}
-
function addTestServerCommand(program: Command) {
const command = program.command('test-server', { hidden: true });
command.description('start test server');
@@ -237,6 +225,5 @@ addShowReportCommand(program);
addMergeReportsCommand(program);
addClearCacheCommand(program);
addTestMCPServerCommand(program);
-addDevServerCommand(program);
addTestServerCommand(program);
addInitAgentsCommand(program);
diff --git a/packages/playwright/src/fsWatcher.ts b/packages/playwright/src/runner/fsWatcher.ts
similarity index 92%
rename from packages/playwright/src/fsWatcher.ts
rename to packages/playwright/src/runner/fsWatcher.ts
index a6989defcf..bdfa2d75c6 100644
--- a/packages/playwright/src/fsWatcher.ts
+++ b/packages/playwright/src/runner/fsWatcher.ts
@@ -14,18 +14,18 @@
* limitations under the License.
*/
-import { chokidar } from './utilsBundle';
+import { chokidar } from '../utilsBundle';
-import type { FSWatcher } from 'chokidar';
+import type { FSWatcher as ChokidarWatcher } from 'chokidar';
export type FSEvent = { event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', file: string };
-export class Watcher {
+export class FSWatcher {
private _onChange: (events: FSEvent[]) => void;
private _watchedPaths: string[] = [];
private _ignoredFolders: string[] = [];
private _collector: FSEvent[] = [];
- private _fsWatcher: FSWatcher | undefined;
+ private _fsWatcher: ChokidarWatcher | undefined;
private _throttleTimer: NodeJS.Timeout | undefined;
constructor(onChange: (events: FSEvent[]) => void) {
diff --git a/packages/playwright/src/runner/tasks.ts b/packages/playwright/src/runner/tasks.ts
index 57e88ee757..c0a544579c 100644
--- a/packages/playwright/src/runner/tasks.ts
+++ b/packages/playwright/src/runner/tasks.ts
@@ -442,26 +442,3 @@ function createRunTestsTask(): Task<TestRun> {
},
};
}
-
-export function createStartDevServerTask(): Task<TestRun> {
- return {
- title: 'start dev server',
- setup: async ({ config }, errors, softErrors) => {
- if (config.plugins.some(plugin => !!plugin.devServerCleanup)) {
- errors.push({ message: `DevServer is already running` });
- return;
- }
- for (const plugin of config.plugins)
- plugin.devServerCleanup = await plugin.instance?.startDevServer?.();
- if (!config.plugins.some(plugin => !!plugin.devServerCleanup))
- errors.push({ message: `DevServer is not available in the package you are using. Did you mean to use component testing?` });
- },
-
- teardown: async ({ config }) => {
- for (const plugin of config.plugins) {
- await plugin.devServerCleanup?.();
- plugin.devServerCleanup = undefined;
- }
- },
- };
-}
diff --git a/packages/playwright/src/runner/testRunner.ts b/packages/playwright/src/runner/testRunner.ts
index ec86d0ff2c..bf27975734 100644
--- a/packages/playwright/src/runner/testRunner.ts
+++ b/packages/playwright/src/runner/testRunner.ts
@@ -25,7 +25,7 @@ import { setPlaywrightTestProcessEnv } from '@serverUtils/env';
import { gracefullyProcessExitDoNotHang } from '@serverUtils/processLauncher';
import { loadConfig } from '../common/configLoader';
-import { Watcher } from '../fsWatcher';
+import { FSWatcher } from './fsWatcher';
import { baseFullConfig } from '../isomorphic/teleReceiver';
import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin';
import { webServerPluginsForConfig } from '../plugins/webServerPlugin';
@@ -34,7 +34,7 @@ import { InternalReporter } from '../reporters/internalReporter';
import { affectedTestFiles, collectAffectedTestFiles, dependenciesForTestFile } from '../transform/compilationCache';
import { serializeError } from '../util';
import { createErrorCollectingReporter, createReporters } from './reporters';
-import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createListFilesTask, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks, runTasksDeferCleanup } from './tasks';
+import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createListFilesTask, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, runTasks, runTasksDeferCleanup } from './tasks';
import { LastRunReporter } from './lastRun';
import type * as reporterTypes from '../../types/testReporter';
@@ -92,7 +92,7 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {
readonly configLocation: ConfigLocation;
private _configCLIOverrides: ConfigCLIOverrides;
- private _watcher: Watcher;
+ private _watcher: FSWatcher;
private _watchedProjectDirs = new Set<string>();
private _ignoredProjectOutputs = new Set<string>();
private _watchedTestDependencies = new Set<string>();
@@ -100,7 +100,6 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {
private _testRun: { run: Promise<reporterTypes.FullResult['status']>, stop: ManualPromise<void> } | undefined;
private _queue = Promise.resolve();
private _globalSetup: { cleanup: () => Promise<any> } | undefined;
- private _devServer: { cleanup: () => Promise<any> } | undefined;
private _plugins: TestRunnerPluginRegistration[] | undefined;
private _watchTestDirs = false;
private _populateDependenciesOnList = false;
@@ -110,7 +109,7 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {
super();
this.configLocation = configLocation;
this._configCLIOverrides = configCLIOverrides;
- this._watcher = new Watcher(events => {
+ this._watcher = new FSWatcher(events => {
const collector = new Set<string>();
events.forEach(f => collectAffectedTestFiles(f.file, collector));
this.emit(TestRunnerEvent.TestFilesChanged, [...collector]);
@@ -191,33 +190,6 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {
return { status };
}
- async startDevServer(userReporter: AnyReporter, mode: 'in-process' | 'out-of-process'): Promise<{ status: FullResultStatus }> {
- await this.stopDevServer();
-
- const reporter = new InternalReporter([userReporter]);
- const config = await this._loadConfigOrReportError(reporter);
- if (!config)
- return { status: 'failed' };
-
- const { status, cleanup } = await runTasksDeferCleanup(new TestRun(config, reporter), [
- ...createPluginSetupTasks(config),
- createLoadTask(mode, { failOnLoadErrors: true, filterOnly: false }),
- createStartDevServerTask(),
- ]);
- if (status !== 'passed')
- await cleanup();
- else
- this._devServer = { cleanup };
- return { status };
- }
-
- async stopDevServer(): Promise<{ status: FullResultStatus }> {
- const devServer = this._devServer;
- const status = await devServer?.cleanup();
- this._devServer = undefined;
- return { status };
- }
-
async clearCache(userReporter?: AnyReporter): Promise<{ status: FullResultStatus }> {
const reporter = new InternalReporter(userReporter ? [userReporter] : []);
const config = await this._loadConfigOrReportError(reporter);
diff --git a/packages/playwright/src/runner/testServer.ts b/packages/playwright/src/runner/testServer.ts
index 2304818085..9fd07c6ba6 100644
--- a/packages/playwright/src/runner/testServer.ts
+++ b/packages/playwright/src/runner/testServer.ts
@@ -98,7 +98,6 @@ export class TestServerDispatcher implements TestServerInterface {
private _closeOnDisconnect = false;
private _testRunner: TestRunner;
private _globalSetupReport: ReportEntry[] | undefined;
- private _devServerReport: ReportEntry[] | undefined;
readonly _dispatchEvent: TestServerInterfaceEventEmitters['dispatchEvent'];
constructor(configLocation: ConfigLocation, configCLIOverrides: ConfigCLIOverrides) {
@@ -174,21 +173,6 @@ export class TestServerDispatcher implements TestServerInterface {
return { status, report };
}
- async startDevServer(params: Parameters<TestServerInterface['startDevServer']>[0]): ReturnType<TestServerInterface['startDevServer']> {
- await this.stopDevServer({});
-
- const { reporter, report } = await this._collectingReporter();
- const { status } = await this._testRunner.startDevServer(reporter, 'out-of-process');
- return { report, status };
- }
-
- async stopDevServer(params: Parameters<TestServerInterface['stopDevServer']>[0]): ReturnType<TestServerInterface['stopDevServer']> {
- const { status } = await this._testRunner.stopDevServer();
- const report = this._devServerReport || [];
- this._devServerReport = undefined;
- return { status, report };
- }
-
async clearCache(params: Parameters<TestServerInterface['clearCache']>[0]): ReturnType<TestServerInterface['clearCache']> {
await this._testRunner.clearCache();
}
diff --git a/packages/playwright/src/transform/compilationCache.ts b/packages/playwright/src/transform/compilationCache.ts
index 1e81d9c70c..dd6b71a890 100644
--- a/packages/playwright/src/transform/compilationCache.ts
+++ b/packages/playwright/src/transform/compilationCache.ts
@@ -224,7 +224,9 @@ export function setExternalDependencies(filename: string, deps: string[]) {
}
export function fileDependenciesForTest() {
- return fileDependencies;
+ return Object.fromEntries([...fileDependencies.entries()].map(entry => (
+ [path.basename(entry[0]), [...entry[1]].map(f => path.basename(f)).sort()]
+ )));
}
export function collectAffectedTestFiles(changedFile: string, testFileCollector: Set<string>) {
diff --git a/tests/playwright-test/playwright.ct-dev-server.spec.ts b/tests/playwright-test/playwright.ct-dev-server.spec.ts
deleted file mode 100644
index 91edc93740..0000000000
--- a/tests/playwright-test/playwright.ct-dev-server.spec.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { test, expect, playwrightCtConfigText } from './playwright-test-fixtures';
-
-test.describe.configure({ mode: 'parallel' });
-
-test('should run dev-server and use it for tests', async ({ writeFiles, runInlineTest, startCLICommand }) => {
- await writeFiles({
- 'playwright.config.ts': playwrightCtConfigText,
- 'playwright/index.html': `<script type="module" src="./index.ts"></script>`,
- 'playwright/index.ts': ``,
- 'src/button.tsx': `
- export const Button = () => <button>Button</button>;
- `,
- 'src/button.test.tsx': `
- import { test, expect } from '@playwright/experimental-ct-react';
- import { Button } from './button';
-
- test('pass', async ({ mount }) => {
- const component = await mount(<Button></Button>);
- await expect(component).toHaveText('Button', { timeout: 1 });
- });
- `,
- });
-
- const devServerProcess = await startCLICommand({}, 'dev-server');
- await devServerProcess.waitForOutput('Dev Server listening on');
-
- const result = await runInlineTest({}, { workers: 1 });
- expect(result.exitCode).toBe(0);
- expect(result.passed).toBe(1);
- expect(result.output).toContain('Dev Server is already running at');
-
- await devServerProcess.kill();
-});
diff --git a/tests/playwright-test/test-server.spec.ts b/tests/playwright-test/test-server.spec.ts
index 3dff3ac06a..17ac351070 100644
--- a/tests/playwright-test/test-server.spec.ts
+++ b/tests/playwright-test/test-server.spec.ts
@@ -177,23 +177,6 @@ test('stdio interception', async ({ startTestServer, writeFiles }) => {
]));
});
-test('start dev server', async ({ startTestServer, writeFiles, runInlineTest }) => {
- await writeFiles(ctFiles);
-
- const testServerConnection = await startTestServer();
- await testServerConnection.initialize({ interceptStdio: true });
- expect((await testServerConnection.runGlobalSetup({})).status).toBe('passed');
- expect((await testServerConnection.startDevServer({})).status).toBe('passed');
-
- const result = await runInlineTest({}, { workers: 1 });
- expect(result.exitCode).toBe(0);
- expect(result.passed).toBe(1);
- expect(result.output).toContain('Dev Server is already running at');
-
- expect((await testServerConnection.stopDevServer({})).status).toBe('passed');
- expect((await testServerConnection.runGlobalTeardown({})).status).toBe('passed');
-});
-
test('find related test files errors', async ({ startTestServer, writeFiles }) => {
await writeFiles({
'a.spec.ts': `
diff --git a/tests/playwright-test/watch.spec.ts b/tests/playwright-test/watch.spec.ts
index 45395f861b..285254b76b 100644
--- a/tests/playwright-test/watch.spec.ts
+++ b/tests/playwright-test/watch.spec.ts
@@ -41,9 +41,9 @@ test('should print dependencies in CJS mode', async ({ runInlineTest }) => {
test('passes', () => {});
`,
'globalTeardown.ts': `
- import { fileDependencies } from 'playwright/lib/internalsForTest';
+ import { fileDependenciesForTest } from 'playwright/lib/transform/compilationCache';
export default () => {
- console.log('###' + JSON.stringify(fileDependencies()) + '###');
+ console.log('###' + JSON.stringify(fileDependenciesForTest()) + '###');
};
`
}, {});
@@ -80,9 +80,9 @@ test('should print dependencies in ESM mode', async ({ runInlineTest }) => {
test('passes', () => {});
`,
'globalTeardown.ts': `
- import { fileDependencies } from 'playwright/lib/internalsForTest';
+ import { fileDependenciesForTest } from 'playwright/lib/transform/compilationCache';
export default () => {
- console.log('###' + JSON.stringify(fileDependencies()) + '###');
+ console.log('###' + JSON.stringify(fileDependenciesForTest()) + '###');
};
`
}, {});
@@ -119,9 +119,9 @@ test('should print dependencies in mixed CJS/ESM mode 1', async ({ runInlineTest
test('passes', () => {});
`,
'globalTeardown.ts': `
- import { fileDependencies } from 'playwright/lib/internalsForTest';
+ import { fileDependenciesForTest } from 'playwright/lib/transform/compilationCache';
export default () => {
- console.log('###' + JSON.stringify(fileDependencies()) + '###');
+ console.log('###' + JSON.stringify(fileDependenciesForTest()) + '###');
};
`
}, {});
@@ -157,9 +157,9 @@ test('should print dependencies in mixed CJS/ESM mode 2', async ({ runInlineTest
test('passes', () => {});
`,
'globalTeardown.ts': `
- import { fileDependencies } from 'playwright/lib/internalsForTest';
+ import { fileDependenciesForTest } from 'playwright/lib/transform/compilationCache';
export default () => {
- console.log('###' + JSON.stringify(fileDependencies()) + '###');
+ console.log('###' + JSON.stringify(fileDependenciesForTest()) + '###');
};
`
}, {});