diff --git a/packages/playwright/src/runner/watchMode.ts b/packages/playwright/src/runner/watchMode.ts index 7ed7367ffc..15cbebcaf1 100644 --- a/packages/playwright/src/runner/watchMode.ts +++ b/packages/playwright/src/runner/watchMode.ts @@ -119,7 +119,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp } changedFiles.clear(); - if (dirtyTestIds.size > 0) { + if (dirtyTestIds.size > 0) { onDirtyTests.resolve('changed'); onDirtyTests = new ManualPromise(); } @@ -144,10 +144,9 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp else printPrompt(); - const readCommandPromise = readCommand(); const command = await Promise.race([ onDirtyTests, - readCommandPromise, + readCommand(), ]); if (bufferMode && command === 'changed') diff --git a/tests/playwright-test/watch.spec.ts b/tests/playwright-test/watch.spec.ts index 142e6ad2f3..b56fb470ea 100644 --- a/tests/playwright-test/watch.spec.ts +++ b/tests/playwright-test/watch.spec.ts @@ -313,12 +313,17 @@ test('should respect project filter C', async ({ runWatchTest, writeFiles }) => await testProcess.waitForOutput('[foo] › a.test.ts:3:11 › passes'); expect(testProcess.output).not.toContain('[bar] › a.test.ts:3:11 › passes'); + await testProcess.waitForOutput('Waiting for file changes.'); testProcess.clearOutput(); await writeFiles(files); // file change triggers listTests with project filter await testProcess.waitForOutput('[foo] › a.test.ts:3:11 › passes'); + testProcess.clearOutput(); + await testProcess.waitForOutput('Waiting for file changes.'); + testProcess.write('c'); + testProcess.clearOutput(); await testProcess.waitForOutput('Select projects'); await testProcess.waitForOutput('foo'); await testProcess.waitForOutput('bar'); // second selection should still show all