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
fix(watch): cancel waitForCommand when files change (#32761)
Max Schmitt12ecd476dd48
diff --git a/packages/playwright/src/runner/watchMode.ts b/packages/playwright/src/runner/watchMode.tsindex a47ca0fe32..2a2c9802f1 100644--- a/packages/playwright/src/runner/watchMode.ts+++ b/packages/playwright/src/runner/watchMode.ts@@ -144,11 +144,13 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOpelseprintPrompt();+ const waitForCommand = readCommand();const command = await Promise.race([onDirtyTests,- readCommand(),+ waitForCommand.result,]);-+ if (command === 'changed')+ waitForCommand.cancel();if (bufferMode && command === 'changed')continue;@@ -282,7 +284,7 @@ async function runTests(watchOptions: WatchModeOptions, testServerConnection: Te});}-function readCommand(): ManualPromise<Command> {+function readCommand(): { result: Promise<Command>, cancel: () => void } {const result = new ManualPromise<Command>();const rl = readline.createInterface({ input: process.stdin, escapeCodeTimeout: 50 });readline.emitKeypressEvents(process.stdin, rl);@@ -334,13 +336,14 @@ Change settings};process.stdin.on('keypress', handler);- void result.finally(() => {+ const cancel = () => {process.stdin.off('keypress', handler);rl.close();if (process.stdin.isTTY)process.stdin.setRawMode(false);- });- return result;+ };+ void result.finally(cancel);+ return { result, cancel };}let showBrowserServer: PlaywrightServer | undefined;