diff --git a/packages/playwright/src/runner/watchMode.ts b/packages/playwright/src/runner/watchMode.ts index 9c164e7ff3..4528964142 100644 --- a/packages/playwright/src/runner/watchMode.ts +++ b/packages/playwright/src/runner/watchMode.ts @@ -302,7 +302,7 @@ async function runTests(watchOptions: WatchModeOptions, testServerConnection: Te }) { printConfiguration(watchOptions, options?.title); - void readKeyPress((text: string, key: any) => { + const waitForDone = readKeyPress((text: string, key: any) => { if (isInterrupt(text, key)) { testServerConnection.stopTestsNoReply({}); return 'done'; @@ -318,7 +318,7 @@ async function runTests(watchOptions: WatchModeOptions, testServerConnection: Te reuseContext: connectWsEndpoint ? true : undefined, workers: connectWsEndpoint ? 1 : undefined, headed: connectWsEndpoint ? true : undefined, - }); + }).finally(() => waitForDone.cancel()); } function readCommand() {