From a327f8979c4af5541c4f4f6db2e90dda06523d98 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Mon, 26 Aug 2024 09:43:23 +0200 Subject: [PATCH] address the easy ones --- packages/playwright/src/runner/runner.ts | 2 +- packages/playwright/src/runner/watchMode.ts | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/playwright/src/runner/runner.ts b/packages/playwright/src/runner/runner.ts index fd47b03647..c857449851 100644 --- a/packages/playwright/src/runner/runner.ts +++ b/packages/playwright/src/runner/runner.ts @@ -136,7 +136,7 @@ export class Runner { webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p })); return await runWatchModeLoop( { configDir: config.configDir, resolvedConfigFile: config.config.configFile }, - { projects: config.cliProjectFilter, files: config.cliArgs, grep: config.cliGrep, onlyChanged: config.cliOnlyChanged } + { projects: config.cliProjectFilter, files: config.cliArgs, grep: config.cliGrep } ); } diff --git a/packages/playwright/src/runner/watchMode.ts b/packages/playwright/src/runner/watchMode.ts index 87dc6eeb3d..4a8fce88f1 100644 --- a/packages/playwright/src/runner/watchMode.ts +++ b/packages/playwright/src/runner/watchMode.ts @@ -46,6 +46,7 @@ class InMemoryTransport extends EventEmitter implements TestServerTransport { } onerror(listener: () => void): void { + // no-op to fulfil the interface, the user of InMemoryTransport doesn't emit any errors. this.on('error', listener); } @@ -66,7 +67,6 @@ interface WatchModeOptions { files?: string[]; projects?: string[]; grep?: string; - onlyChanged?: string; } export async function runWatchModeLoop(configLocation: ConfigLocation, initialOptions: WatchModeOptions): Promise { @@ -90,7 +90,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp const testServerConnection = new TestServerConnection(transport); transport.emit('open'); - const telesuiteUpdater = new TeleSuiteUpdater({ pathSeparator: path.sep, onUpdate() { } }); + const teleSuiteUpdater = new TeleSuiteUpdater({ pathSeparator: path.sep, onUpdate() { } }); const dirtyTestFiles = new Set(); const onDirtyTestFiles: { resolve?(): void } = {}; @@ -100,9 +100,9 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp return; const { report } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep }); - telesuiteUpdater.processListReport(report); + teleSuiteUpdater.processListReport(report); - for (const project of telesuiteUpdater.rootSuite!.suites) { + for (const project of teleSuiteUpdater.rootSuite!.suites) { for (const suite of project.suites) { if (suite.location?.file && changedFiles.includes(suite.location.file)) dirtyTestFiles.add(suite.location.file); @@ -114,13 +114,13 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp onDirtyTestFiles.resolve?.(); }); - testServerConnection.onReport(report => telesuiteUpdater.processTestReportEvent(report)); + testServerConnection.onReport(report => teleSuiteUpdater.processTestReportEvent(report)); await testServerConnection.initialize({ interceptStdio: false, watchTestDirs: true }); await testServerConnection.runGlobalSetup({}); const { report } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep }); - telesuiteUpdater.processListReport(report); + teleSuiteUpdater.processListReport(report); let lastRun: { type: 'changed' | 'regular' | 'failed', failedTestIds?: string[], dirtyTestFiles?: string[] } = { type: 'regular' }; let result: FullResult['status'] = 'passed'; @@ -160,7 +160,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp type: 'multiselect', name: 'selectedProjects', message: 'Select projects', - choices: telesuiteUpdater.rootSuite!.suites.map(s => s.title), + choices: teleSuiteUpdater.rootSuite!.suites.map(s => s.title), }).catch(() => ({ selectedProjects: null })); if (!selectedProjects) continue; @@ -205,7 +205,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp } if (command === 'failed') { - const failedTestIds = telesuiteUpdater.rootSuite!.allTests().filter(t => !t.ok()).map(t => t.id); + const failedTestIds = teleSuiteUpdater.rootSuite!.allTests().filter(t => !t.ok()).map(t => t.id); await runTests({}, testServerConnection, { title: 'running failed tests', testIds: failedTestIds }); lastRun = { type: 'failed', failedTestIds }; continue; @@ -340,8 +340,6 @@ function printConfiguration(options: WatchModeOptions, title?: string) { tokens.push(...options.projects.map(p => colors.blue(`--project ${p}`))); if (options.grep) tokens.push(colors.red(`--grep ${options.grep}`)); - if (options.onlyChanged) - tokens.push(colors.yellow(`--only-changed ${options.onlyChanged}`)); if (options.files) tokens.push(...options.files.map(a => colors.bold(a))); if (title)