From 6b0a7003c4e2d155fdb04301dd8e6b2e52646a85 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Wed, 8 Feb 2023 18:53:07 -0800 Subject: [PATCH] chore(watch): run by default again (#20763) --- packages/playwright-core/src/server/page.ts | 2 +- .../playwright-test/src/runner/watchMode.ts | 45 ++++++++++--------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/packages/playwright-core/src/server/page.ts b/packages/playwright-core/src/server/page.ts index 266366c214..be3043e97e 100644 --- a/packages/playwright-core/src/server/page.ts +++ b/packages/playwright-core/src/server/page.ts @@ -247,7 +247,7 @@ export class Page extends SdkObject { this._interceptFileChooser = false; await Promise.all([ - this._delegate.updateEmulatedViewportSize(true), + this._delegate.updateEmulatedViewportSize(), this._delegate.updateEmulateMedia(), this._delegate.updateFileChooserInterception(), ]); diff --git a/packages/playwright-test/src/runner/watchMode.ts b/packages/playwright-test/src/runner/watchMode.ts index 825161f0fc..ef3090f15c 100644 --- a/packages/playwright-test/src/runner/watchMode.ts +++ b/packages/playwright-test/src/runner/watchMode.ts @@ -94,7 +94,8 @@ export async function runWatchModeLoop(config: FullConfigInternal): Promise ({ projectNames: null })); if (!projectNames) continue; - config._internal.cliProjectFilter = projectNames; - printConfiguration(config); + config._internal.cliProjectFilter = projectNames.length ? projectNames : undefined; + await runTests(config, failedTestIdCollector); + lastRun = { type: 'regular' }; continue; } @@ -149,7 +149,8 @@ export async function runWatchModeLoop(config: FullConfigInternal): Promise failedTestIdCollector.has(id); const failedTestIds = new Set(failedTestIdCollector); - printConfiguration(config, 'running failed tests'); - await runTests(config, failedTestIdCollector); + await runTests(config, failedTestIdCollector, { title: 'running failed tests' }); config._internal.testIdMatcher = undefined; lastRun = { type: 'failed', failedTestIds }; continue; } if (command === 'repeat') { - printConfiguration(config, 're-running tests'); if (lastRun.type === 'regular') { - await runTests(config, failedTestIdCollector); + await runTests(config, failedTestIdCollector, { title: 're-running tests' }); continue; } else if (lastRun.type === 'changed') { - await runChangedTests(config, failedTestIdCollector, projectClosure, lastRun.dirtyFiles!); + await runChangedTests(config, failedTestIdCollector, projectClosure, lastRun.dirtyFiles!, 're-running tests'); } else if (lastRun.type === 'failed') { config._internal.testIdMatcher = id => lastRun.failedTestIds!.has(id); - await runTests(config, failedTestIdCollector); + await runTests(config, failedTestIdCollector, { title: 're-running tests' }); config._internal.testIdMatcher = undefined; } continue; @@ -211,7 +211,7 @@ export async function runWatchModeLoop(config: FullConfigInternal): Promise, projectClosure: FullProjectInternal[], changedFiles: Set) { +async function runChangedTests(config: FullConfigInternal, failedTestIdCollector: Set, projectClosure: FullProjectInternal[], changedFiles: Set, title?: string) { const commandLineFileMatcher = config._internal.cliArgs.length ? createFileMatcherFromArguments(config._internal.cliArgs) : () => true; // Resolve files that depend on the changed files. @@ -242,15 +242,20 @@ async function runChangedTests(config: FullConfigInternal, failedTestIdCollector // If there are affected dependency projects, do the full run, respect the original CLI. // if there are no affected dependency projects, intersect CLI with dirty files const additionalFileMatcher = affectsAnyDependency ? () => true : (file: string) => testFiles.has(file); - return await runTests(config, failedTestIdCollector, projectsToIgnore, additionalFileMatcher); + return await runTests(config, failedTestIdCollector, { projectsToIgnore, additionalFileMatcher, title: title || 'files changed' }); } let seq = 0; -async function runTests(config: FullConfigInternal, failedTestIdCollector: Set, projectsToIgnore?: Set, additionalFileMatcher?: Matcher) { +async function runTests(config: FullConfigInternal, failedTestIdCollector: Set, options?: { + projectsToIgnore?: Set, + additionalFileMatcher?: Matcher, + title?: string, + }) { ++seq; + printConfiguration(config, options?.title); const reporter = new Multiplexer([new ListReporter()]); - const taskRunner = createTaskRunnerForWatch(config, reporter, projectsToIgnore, additionalFileMatcher); + const taskRunner = createTaskRunnerForWatch(config, reporter, options?.projectsToIgnore, options?.additionalFileMatcher); const context: TaskRunnerState = { config, reporter, @@ -263,11 +268,11 @@ async function runTests(config: FullConfigInternal, failedTestIdCollector: Set