From b97bed5e31f85a04044f965dfa3e42dea7e6b47d Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 3 Sep 2024 09:36:59 +0200 Subject: [PATCH] one listTests at a time --- packages/playwright/src/runner/watchMode.ts | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/playwright/src/runner/watchMode.ts b/packages/playwright/src/runner/watchMode.ts index 23edfd8d02..924449adce 100644 --- a/packages/playwright/src/runner/watchMode.ts +++ b/packages/playwright/src/runner/watchMode.ts @@ -98,26 +98,26 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp let onDirtyTests = new ManualPromise(); let queue = Promise.resolve(); - - testServerConnection.onTestFilesChanged(({ testFiles: changedFiles }) => { - if (changedFiles.length === 0) - return; + const changedFiles = new Set(); + testServerConnection.onTestFilesChanged(({ testFiles }) => { + testFiles.forEach(file => changedFiles.add(file)); queue = queue.then(async () => { + if (changedFiles.size === 0) + return; + const { report } = await testServerConnection.listTests({ locations: options.files, projects: options.projects, grep: options.grep }); teleSuiteUpdater.processListReport(report); for (const test of teleSuiteUpdater.rootSuite!.allTests()) { - if (changedFiles.includes(test.location.file)) + if (changedFiles.has(test.location.file)) dirtyTestIds.add(test.id); } - // listTests can take longer than the debouncing interval of onTestFilesChanged, - // so the queue might contain another set of changed files to be processed before executing tests. - queue = queue.then(() => { - if (dirtyTestIds.size > 0) - onDirtyTests.resolve?.(); - }); + changedFiles.clear(); + + if (dirtyTestIds.size > 0) + onDirtyTests.resolve?.(); }); }); testServerConnection.onReport(report => teleSuiteUpdater.processTestReportEvent(report));