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: merge runner into test runner (#37042)
Pavel Feldmandc94a0b780b8
diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.tsindex b57fda08bc..5e955dbce7 100644--- a/packages/playwright/src/program.ts+++ b/packages/playwright/src/program.ts@@ -25,16 +25,15 @@ import { gracefullyProcessExitDoNotHang, startProfiling, stopProfiling } from 'pimport { builtInReporters, defaultReporter, defaultTimeout } from './common/config';import { loadConfigFromFile, loadEmptyConfigForMergeReports, resolveConfigLocation } from './common/configLoader';export { program } from 'playwright-core/lib/cli/program';-import { prepareErrorStack } from './reporters/base';+import { terminalScreen } from './reporters/base';import { showHTMLReport } from './reporters/html';import { createMergedReport } from './reporters/merge';import { filterProjects } from './runner/projectUtils';-import { Runner } from './runner/runner';import * as testServer from './runner/testServer';import { runWatchModeLoop } from './runner/watchMode';-import { serializeError } from './util';+import { runAllTestsWithConfig, TestRunner } from './runner/testRunner';+import { createErrorCollectingReporter } from './runner/reporters';-import type { TestError } from '../types/testReporter';import type { ConfigCLIOverrides } from './common/ipc';import type { TraceMode } from '../types/test';import type { ReporterDescription } from '../types/test';@@ -74,47 +73,25 @@ Examples:$ npx playwright test --project=webkit`);}-function addListFilesCommand(program: Command) {- const command = program.command('list-files [file-filter...]', { hidden: true });- command.description('List files with Playwright Test tests');- command.option('-c, --config <file>', `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);- command.option('--project <project-name...>', `Only run tests from the specified list of projects, supports '*' wildcard (default: list all projects)`);- command.action(async (args, opts) => listTestFiles(opts));-}-function addClearCacheCommand(program: Command) {const command = program.command('clear-cache');command.description('clears build and test caches');command.option('-c, --config <file>', `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);command.action(async opts => {- const config = await loadConfigFromFile(opts.config);- const runner = new Runner(config);- const { status } = await runner.clearCache();+ const runner = new TestRunner(resolveConfigLocation(opts.config), {});+ const { status } = await runner.clearCache(createErrorCollectingReporter(terminalScreen));const exitCode = status === 'interrupted' ? 130 : (status === 'passed' ? 0 : 1);gracefullyProcessExitDoNotHang(exitCode);});}-function addFindRelatedTestFilesCommand(program: Command) {- const command = program.command('find-related-test-files [source-files...]', { hidden: true });- command.description('Returns the list of related tests to the given files');- command.option('-c, --config <file>', `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);- command.action(async (files, options) => {- const resolvedFiles = (files as string[]).map(file => path.resolve(process.cwd(), file));- await withRunnerAndMutedWrite(options.config, runner => runner.findRelatedTestFiles(resolvedFiles));- });-}-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 => {- const config = await loadConfigFromFile(options.config);- const runner = new Runner(config);- const { status } = await runner.runDevServer();- const exitCode = status === 'interrupted' ? 130 : (status === 'passed' ? 0 : 1);- gracefullyProcessExitDoNotHang(exitCode);+ const runner = new TestRunner(resolveConfigLocation(options.config), {});+ await runner.startDevServer(createErrorCollectingReporter(terminalScreen), 'in-process');});}@@ -217,8 +194,7 @@ async function runTests(args: string[], opts: { [key: string]: any }) {return;}- const runner = new Runner(config);- const status = await runner.runAllTests();+ const status = await runAllTestsWithConfig(config);await stopProfiling('runner');const exitCode = status === 'interrupted' ? 130 : (status === 'passed' ? 0 : 1);gracefullyProcessExitDoNotHang(exitCode);@@ -232,34 +208,6 @@ async function runTestServer(opts: { [key: string]: any }) {gracefullyProcessExitDoNotHang(exitCode);}-export async function withRunnerAndMutedWrite(configFile: string | undefined, callback: (runner: Runner) => Promise<any>) {- // Redefine process.stdout.write in case config decides to pollute stdio.- // eslint-disable-next-line no-restricted-properties- const stdoutWrite = process.stdout.write.bind(process.stdout);- // eslint-disable-next-line no-restricted-properties- process.stdout.write = ((a: any, b: any, c: any) => process.stderr.write(a, b, c)) as any;- try {- const config = await loadConfigFromFile(configFile);- const runner = new Runner(config);- const result = await callback(runner);- stdoutWrite(JSON.stringify(result, undefined, 2), () => {- gracefullyProcessExitDoNotHang(0);- });- } catch (e) {- const error: TestError = serializeError(e);- error.location = prepareErrorStack(e.stack).location;- stdoutWrite(JSON.stringify({ error }, undefined, 2), () => {- gracefullyProcessExitDoNotHang(0);- });- }-}--async function listTestFiles(opts: { [key: string]: any }) {- await withRunnerAndMutedWrite(opts.config, async runner => {- return await runner.listTestFiles();- });-}-async function mergeReports(reportDir: string | undefined, opts: { [key: string]: any }) {const configFile = opts.config;const config = configFile ? await loadConfigFromFile(configFile) : await loadEmptyConfigForMergeReports();@@ -416,9 +364,7 @@ const testOptions: [string, { description: string, choices?: string[], preset?:addTestCommand(program);addShowReportCommand(program);-addListFilesCommand(program);addMergeReportsCommand(program);addClearCacheCommand(program);-addFindRelatedTestFilesCommand(program);addDevServerCommand(program);addTestServerCommand(program);diff --git a/packages/playwright/src/runner/reporters.ts b/packages/playwright/src/runner/reporters.tsindex afe8a4c005..043a4df407 100644--- a/packages/playwright/src/runner/reporters.ts+++ b/packages/playwright/src/runner/reporters.ts@@ -91,14 +91,13 @@ interface ErrorCollectingReporter extends ReporterV2 {errors(): TestError[];}-export function createErrorCollectingReporter(screen: Screen, writeToConsole?: boolean): ErrorCollectingReporter {+export function createErrorCollectingReporter(screen: Screen): ErrorCollectingReporter {const errors: TestError[] = [];return {version: () => 'v2',onError(error: TestError) {errors.push(error);- if (writeToConsole)- screen.stderr?.write(formatError(screen, error).message + '\n');+ screen.stderr?.write(formatError(screen, error).message + '\n');},errors: () => errors,};diff --git a/packages/playwright/src/runner/runner.ts b/packages/playwright/src/runner/runner.tsdeleted file mode 100644index 3736b95beb..0000000000--- a/packages/playwright/src/runner/runner.ts+++ /dev/null@@ -1,139 +0,0 @@-/**- * Copyright 2019 Google Inc. All rights reserved.- * Modifications 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 { LastRunReporter } from './lastRun';-import { collectFilesForProject, filterProjects } from './projectUtils';-import { createErrorCollectingReporter, createReporters } from './reporters';-import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks } from './tasks';-import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin';-import { webServerPluginsForConfig } from '../plugins/webServerPlugin';-import { terminalScreen } from '../reporters/base';-import { InternalReporter } from '../reporters/internalReporter';-import { affectedTestFiles } from '../transform/compilationCache';--import type { FullResult, TestError } from '../../types/testReporter';-import type { FullConfigInternal } from '../common/config';---type ProjectConfigWithFiles = {- name: string;- testDir: string;- use: { testIdAttribute?: string };- files: string[];-};--type ConfigListFilesReport = {- projects: ProjectConfigWithFiles[];- error?: TestError;-};--export type FindRelatedTestFilesReport = {- testFiles: string[];- errors?: TestError[];-};--export class Runner {- private _config: FullConfigInternal;-- constructor(config: FullConfigInternal) {- this._config = config;- }-- async listTestFiles(projectNames?: string[]): Promise<ConfigListFilesReport> {- const projects = filterProjects(this._config.projects, projectNames);- const report: ConfigListFilesReport = {- projects: [],- };- for (const project of projects) {- report.projects.push({- name: project.project.name,- testDir: project.project.testDir,- use: { testIdAttribute: project.project.use.testIdAttribute },- files: await collectFilesForProject(project)- });- }- return report;- }-- async runAllTests(): Promise<FullResult['status']> {- const config = this._config;- const listOnly = config.cliListOnly;-- addGitCommitInfoPlugin(config);-- // Legacy webServer support.- webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p }));-- const reporters = await createReporters(config, listOnly ? 'list' : 'test', false);- const lastRun = new LastRunReporter(config);- if (config.cliLastFailed)- await lastRun.filterLastFailed();-- const reporter = new InternalReporter([...reporters, lastRun]);- const tasks = listOnly ? [- createLoadTask('in-process', { failOnLoadErrors: true, filterOnly: false }),- createReportBeginTask(),- ] : [- createApplyRebaselinesTask(),- ...createGlobalSetupTasks(config),- createLoadTask('in-process', { filterOnly: true, failOnLoadErrors: true }),- ...createRunTestsTasks(config),- ];- const status = await runTasks(new TestRun(config, reporter), tasks, config.config.globalTimeout);-- // Calling process.exit() might truncate large stdout/stderr output.- // See https://github.com/nodejs/node/issues/6456.- // See https://github.com/nodejs/node/issues/12921- // eslint-disable-next-line no-restricted-properties- await new Promise<void>(resolve => process.stdout.write('', () => resolve()));- // eslint-disable-next-line no-restricted-properties- await new Promise<void>(resolve => process.stderr.write('', () => resolve()));- return status;- }-- async findRelatedTestFiles(files: string[]): Promise<FindRelatedTestFilesReport> {- const errorReporter = createErrorCollectingReporter(terminalScreen);- const reporter = new InternalReporter([errorReporter]);- const status = await runTasks(new TestRun(this._config, reporter), [- ...createPluginSetupTasks(this._config),- createLoadTask('in-process', { failOnLoadErrors: true, filterOnly: false, populateDependencies: true }),- ]);- if (status !== 'passed')- return { errors: errorReporter.errors(), testFiles: [] };- return { testFiles: affectedTestFiles(files) };- }-- async runDevServer() {- const reporter = new InternalReporter([createErrorCollectingReporter(terminalScreen, true)]);- const status = await runTasks(new TestRun(this._config, reporter), [- ...createPluginSetupTasks(this._config),- createLoadTask('in-process', { failOnLoadErrors: true, filterOnly: false }),- createStartDevServerTask(),- { title: 'wait until interrupted', setup: async () => new Promise(() => {}) },- ]);- return { status };- }-- async clearCache() {- const reporter = new InternalReporter([createErrorCollectingReporter(terminalScreen, true)]);- const status = await runTasks(new TestRun(this._config, reporter), [- ...createPluginSetupTasks(this._config),- createClearCacheTask(this._config),- ]);- return { status };- }-}diff --git a/packages/playwright/src/runner/testRunner.ts b/packages/playwright/src/runner/testRunner.tsindex 3f0f5b81c7..cae7a9ea0e 100644--- a/packages/playwright/src/runner/testRunner.ts+++ b/packages/playwright/src/runner/testRunner.ts@@ -31,15 +31,20 @@ 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, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks, runTasksDeferCleanup } from './tasks';+import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createListFilesTask, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks, runTasksDeferCleanup } from './tasks';+import { LastRunReporter } from './lastRun';import type * as reporterTypes from '../../types/testReporter';import type { ConfigLocation, FullConfigInternal } from '../common/config';import type { ConfigCLIOverrides } from '../common/ipc';-import type { RecoverFromStepErrorResult, TestServerInterface } from '../isomorphic/testServerInterface';import type { TestRunnerPluginRegistration } from '../plugins';import type { ReporterV2 } from '../reporters/reporterV2';+export type RecoverFromStepErrorResult = {+ stepId: string;+ status: 'recovered' | 'failed';+ value?: string | number | boolean | undefined;+};export const TestRunnerEvent = {TestFilesChanged: 'testFilesChanged',@@ -167,16 +172,17 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {return { status };}- async startDevServer(userReporters: ReporterV2[]): Promise<{ status: FullResultStatus }> {+ async startDevServer(userReporter: ReporterV2, mode: 'in-process' | 'out-of-process'): Promise<{ status: FullResultStatus }> {await this.stopDevServer();- const reporter = new InternalReporter(userReporters);+ 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), [- createLoadTask('out-of-process', { failOnLoadErrors: true, filterOnly: false }),+ ...createPluginSetupTasks(config),+ createLoadTask(mode, { failOnLoadErrors: true, filterOnly: false }),createStartDevServerTask(),]);if (status !== 'passed')@@ -193,23 +199,25 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {return { status };}- async clearCache(): Promise<void> {- const reporter = new InternalReporter([]);+ async clearCache(userReporter?: ReporterV2): Promise<{ status: FullResultStatus }> {+ const reporter = new InternalReporter(userReporter ? [userReporter] : []);const config = await this._loadConfigOrReportError(reporter);if (!config)- return;- await runTasks(new TestRun(config, reporter), [+ return { status: 'failed' };+ const status = await runTasks(new TestRun(config, reporter), [+ ...createPluginSetupTasks(config),createClearCacheTask(config),]);+ return { status };}- async listFiles(userReporters: ReporterV2[], params: { projects?: string[] }): Promise<{ status: FullResultStatus }> {- const reporter = new InternalReporter(userReporters);+ async listFiles(userReporter: ReporterV2, projects?: string[]): Promise<{ status: FullResultStatus }> {+ const reporter = new InternalReporter([userReporter]);const config = await this._loadConfigOrReportError(reporter);if (!config)return { status: 'failed' };- config.cliProjectFilter = params.projects?.length ? params.projects : undefined;+ config.cliProjectFilter = projects?.length ? projects : undefined;const status = await runTasks(new TestRun(config, reporter), [createListFilesTask(),createReportBeginTask(),@@ -217,10 +225,10 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {return { status };}- async listTests(userReporters: ReporterV2[], params: ListTestsParams): Promise<{ status: FullResultStatus }> {+ async listTests(userReporter: ReporterV2, params: ListTestsParams): Promise<{ status: FullResultStatus }> {let result: { status: FullResultStatus } | undefined;this._queue = this._queue.then(async () => {- const { config, status } = await this._innerListTests(userReporters, params);+ const { config, status } = await this._innerListTests(userReporter, params);if (config)await this._updateWatchedDirs(config);result = { status };@@ -229,7 +237,7 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {return result!;}- private async _innerListTests(userReporters: ReporterV2[], params: ListTestsParams): Promise<{+ private async _innerListTests(userReporter: ReporterV2, params: ListTestsParams): Promise<{status: reporterTypes.FullResult['status'],config?: FullConfigInternal,}> {@@ -238,7 +246,7 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {repeatEach: 1,retries: 0,};- const reporter = new InternalReporter(userReporters);+ const reporter = new InternalReporter([userReporter]);const config = await this._loadConfigOrReportError(reporter, overrides);if (!config)return { status: 'failed' };@@ -278,16 +286,16 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {await this._watcher.update([...this._watchedProjectDirs, ...this._watchedTestDependencies], [...this._ignoredProjectOutputs], reportPending);}- async runTests(userReporters: ReporterV2[], params: RunTestsParams): ReturnType<TestServerInterface['runTests']> {- let result: Awaited<ReturnType<TestServerInterface['runTests']>> = { status: 'passed' };+ async runTests(userReporter: ReporterV2, params: RunTestsParams): Promise<{ status: FullResultStatus }> {+ let result: { status: FullResultStatus } = { status: 'passed' };this._queue = this._queue.then(async () => {- result = await this._innerRunTests(userReporters, params).catch(e => { printInternalError(e); return { status: 'failed' }; });+ result = await this._innerRunTests(userReporter, params).catch(e => { printInternalError(e); return { status: 'failed' }; });});await this._queue;return result;}- private async _innerRunTests(userReporters: ReporterV2[], params: RunTestsParams): ReturnType<TestServerInterface['runTests']> {+ private async _innerRunTests(userReporter: ReporterV2, params: RunTestsParams): Promise<{ status: FullResultStatus }> {await this.stopTests();const overrides: ConfigCLIOverrides = {...this._configCLIOverrides,@@ -313,7 +321,7 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {elseprocess.env.PW_LIVE_TRACE_STACKS = undefined;- const config = await this._loadConfigOrReportError(new InternalReporter(userReporters), overrides);+ const config = await this._loadConfigOrReportError(new InternalReporter([userReporter]), overrides);if (!config)return { status: 'failed' };@@ -330,7 +338,7 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {}const configReporters = await createReporters(config, 'test', true);- const reporter = new InternalReporter([...configReporters, ...userReporters]);+ const reporter = new InternalReporter([...configReporters, userReporter]);const stop = new ManualPromise();const tasks = [createApplyRebaselinesTask(),@@ -367,27 +375,28 @@ export class TestRunner extends EventEmitter<TestRunnerEventMap> {recoveryPromise.resolve(params);}- async watch(params: { fileNames: string[]; }) {+ async watch(fileNames: string[]) {this._watchedTestDependencies = new Set();- for (const fileName of params.fileNames) {+ for (const fileName of fileNames) {this._watchedTestDependencies.add(fileName);dependenciesForTestFile(fileName).forEach(file => this._watchedTestDependencies.add(file));}await this._updateWatcher(true);}- async findRelatedTestFiles(params: Parameters<TestServerInterface['findRelatedTestFiles']>[0]): ReturnType<TestServerInterface['findRelatedTestFiles']> {+ async findRelatedTestFiles(files: string[], userReporter?: ReporterV2): Promise<{ testFiles: string[]; errors?: reporterTypes.TestError[]; }> {const errorReporter = createErrorCollectingReporter(internalScreen);- const reporter = new InternalReporter([errorReporter]);+ const reporter = new InternalReporter(userReporter ? [userReporter, errorReporter] : [errorReporter]);const config = await this._loadConfigOrReportError(reporter);if (!config)return { errors: errorReporter.errors(), testFiles: [] };const status = await runTasks(new TestRun(config, reporter), [+ ...createPluginSetupTasks(config),createLoadTask('out-of-process', { failOnLoadErrors: true, filterOnly: false, populateDependencies: true }),]);if (status !== 'passed')return { errors: errorReporter.errors(), testFiles: [] };- return { testFiles: affectedTestFiles(params.files) };+ return { testFiles: affectedTestFiles(files) };}async stopTests() {@@ -448,3 +457,38 @@ async function resolveCtDirs(config: FullConfigInternal) {templateDir};}++export async function runAllTestsWithConfig(config: FullConfigInternal): Promise<FullResultStatus> {+ const listOnly = config.cliListOnly;++ addGitCommitInfoPlugin(config);++ // Legacy webServer support.+ webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p }));++ const reporters = await createReporters(config, listOnly ? 'list' : 'test', false);+ const lastRun = new LastRunReporter(config);+ if (config.cliLastFailed)+ await lastRun.filterLastFailed();++ const reporter = new InternalReporter([...reporters, lastRun]);+ const tasks = listOnly ? [+ createLoadTask('in-process', { failOnLoadErrors: true, filterOnly: false }),+ createReportBeginTask(),+ ] : [+ createApplyRebaselinesTask(),+ ...createGlobalSetupTasks(config),+ createLoadTask('in-process', { filterOnly: true, failOnLoadErrors: true }),+ ...createRunTestsTasks(config),+ ];+ const status = await runTasks(new TestRun(config, reporter), tasks, config.config.globalTimeout);++ // Calling process.exit() might truncate large stdout/stderr output.+ // See https://github.com/nodejs/node/issues/6456.+ // See https://github.com/nodejs/node/issues/12921+ // eslint-disable-next-line no-restricted-properties+ await new Promise<void>(resolve => process.stdout.write('', () => resolve()));+ // eslint-disable-next-line no-restricted-properties+ await new Promise<void>(resolve => process.stderr.write('', () => resolve()));+ return status;+}diff --git a/packages/playwright/src/runner/testServer.ts b/packages/playwright/src/runner/testServer.tsindex 1418fddfc7..9461e20e05 100644--- a/packages/playwright/src/runner/testServer.ts+++ b/packages/playwright/src/runner/testServer.ts@@ -185,7 +185,7 @@ export class TestServerDispatcher implements TestServerInterface {await this.stopDevServer({});const { reporter, report } = await this._collectingReporter();- const { status } = await this._testRunner.startDevServer([reporter]);+ const { status } = await this._testRunner.startDevServer(reporter, 'out-of-process');return { report, status };}@@ -202,19 +202,19 @@ export class TestServerDispatcher implements TestServerInterface {async listFiles(params: Parameters<TestServerInterface['listFiles']>[0]): ReturnType<TestServerInterface['listFiles']> {const { reporter, report } = await this._collectingReporter();- const { status } = await this._testRunner.listFiles([reporter], params);+ const { status } = await this._testRunner.listFiles(reporter, params.projects);return { report, status };}async listTests(params: Parameters<TestServerInterface['listTests']>[0]): ReturnType<TestServerInterface['listTests']> {const { reporter, report } = await this._collectingReporter();- const { status } = await this._testRunner.listTests([reporter], params);+ const { status } = await this._testRunner.listTests(reporter, params);return { report, status };}async runTests(params: Parameters<TestServerInterface['runTests']>[0]): ReturnType<TestServerInterface['runTests']> {const wireReporter = await this._wireReporter(e => this._dispatchEvent('report', e));- const { status } = await this._testRunner.runTests([wireReporter], params);+ const { status } = await this._testRunner.runTests(wireReporter, params);return { status };}@@ -223,11 +223,11 @@ export class TestServerDispatcher implements TestServerInterface {}async watch(params: { fileNames: string[]; }) {- await this._testRunner.watch(params);+ await this._testRunner.watch(params.fileNames);}async findRelatedTestFiles(params: Parameters<TestServerInterface['findRelatedTestFiles']>[0]): ReturnType<TestServerInterface['findRelatedTestFiles']> {- return this._testRunner.findRelatedTestFiles(params);+ return this._testRunner.findRelatedTestFiles(params.files);}async stopTests() {diff --git a/tests/playwright-test/find-related-tests.spec.ts b/tests/playwright-test/find-related-tests.spec.tsdeleted file mode 100644index 66c7af0122..0000000000--- a/tests/playwright-test/find-related-tests.spec.ts+++ /dev/null@@ -1,100 +0,0 @@-/**- * Copyright Microsoft Corporation. All rights reserved.- *- * 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 } from './playwright-test-fixtures';--test('should list related tests', async ({ runCLICommand }) => {- const result = await runCLICommand({- 'playwright.config.ts': `- import { defineConfig } from '@playwright/test';- export default defineConfig({});- `,- 'helper.ts': `- export const value = 42;- `,- 'helper2.ts': `- export { value } from './helper';- `,- 'a.spec.ts': `- import { test } from '@playwright/test';- import { value } from './helper2';- if (value) {}- test('', () => {});- `,- 'b.spec.ts': `- import { test } from '@playwright/test';- import { value } from './helper';- if (value) {}- test('', () => {});- `,- }, 'find-related-test-files', ['helper.ts']);- expect(result.exitCode).toBe(0);- expect(result.stderr).toBeFalsy();- const data = JSON.parse(result.stdout);- expect(data).toEqual({- testFiles: [- expect.stringContaining('a.spec.ts'),- expect.stringContaining('b.spec.ts'),- ]- });-});--test('should list related tests for ct', async ({ runCLICommand }) => {- const result = await runCLICommand({- 'playwright.config.ts': `- import { defineConfig } from '@playwright/experimental-ct-react';- export default defineConfig({});- `,- 'playwright/index.html': `<script type="module" src="./index.js"></script>`,- 'playwright/index.js': ``,- 'helper.tsx': `- export const HelperButton = () => <button>Click me</button>;- `,- 'button.tsx': `- import { HelperButton } from './helper';- export const Button = () => <HelperButton>Click me</HelperButton>;- `,- 'button.spec.tsx': `- import { test } from '@playwright/experimental-ct-react';- import { Button } from './button';- test('foo', async ({ mount }) => {- await mount(<Button />);- });- `,- }, 'find-related-test-files', ['helper.tsx']);- expect(result.exitCode).toBe(0);- const data = JSON.parse(result.stdout);- expect(data).toEqual({- testFiles: [- expect.stringContaining('button.spec.tsx'),- ]- });-});--test('should return errors', async ({ runCLICommand }) => {- const result = await runCLICommand({- 'a.spec.ts': `- const a = 1;- const a = 2;- `,- }, 'find-related-test-files', ['a.spec.ts']);- expect(result.exitCode).toBe(0);- const data = JSON.parse(result.stdout);- expect(data).toEqual({ testFiles: [], errors: [- expect.objectContaining({ message: expect.stringContaining(`Identifier 'a' has already been declared`) }),- expect.objectContaining({ message: expect.stringContaining(`No tests found`) }),- ] });-});diff --git a/tests/playwright-test/list-files.spec.ts b/tests/playwright-test/list-files.spec.tsdeleted file mode 100644index 80df3a0e5b..0000000000--- a/tests/playwright-test/list-files.spec.ts+++ /dev/null@@ -1,101 +0,0 @@-/**- * Copyright Microsoft Corporation. All rights reserved.- *- * 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 } from './playwright-test-fixtures';--test('should list files', async ({ runCLICommand }) => {- const result = await runCLICommand({- 'playwright.config.ts': `- module.exports = { projects: [{ name: 'foo' }, { name: 'bar' }] };- `,- 'a.test.js': ``- }, 'list-files');- expect(result.exitCode).toBe(0);-- const data = JSON.parse(result.stdout);- expect(data).toEqual({- projects: [- {- name: 'foo',- testDir: expect.stringContaining('list-files-should-list-files-playwright-test'),- use: {},- files: [- expect.stringContaining('a.test.js')- ]- },- {- name: 'bar',- testDir: expect.stringContaining('list-files-should-list-files-playwright-test'),- use: {},- files: [- expect.stringContaining('a.test.js')- ]- }- ]- });-});--test('should include testIdAttribute', async ({ runCLICommand }) => {- const result = await runCLICommand({- 'playwright.config.ts': `- module.exports = {- use: { testIdAttribute: 'myid' }- };- `,- 'a.test.js': ``- }, 'list-files');- expect(result.exitCode).toBe(0);-- const data = JSON.parse(result.stdout);- expect(data).toEqual({- projects: [- {- name: '',- testDir: expect.stringContaining('list-files-should-include-testIdAttribute-playwright-test'),- use: {- testIdAttribute: 'myid'- },- files: [- expect.stringContaining('a.test.js')- ]- },- ]- });-});--test('should report error', async ({ runCLICommand }) => {- const result = await runCLICommand({- 'playwright.config.ts': `- const a = 1;- a = 2;- `,- 'a.test.js': ``- }, 'list-files');- expect(result.exitCode).toBe(0);-- const data = JSON.parse(result.stdout);- expect(data).toEqual({- error: {- location: {- file: expect.stringContaining('playwright.config.ts'),- line: 3,- column: 8,- },- message: 'TypeError: Assignment to constant variable.',- stack: expect.stringContaining('TypeError: Assignment to constant variable.'),- }- });-});