Skip to content

fix(reporter): expose setup/teardown projects to preprocessSuite#41731

Open
Skn0tt wants to merge 6 commits into
microsoft:mainfrom
Skn0tt:skn0tt-preprocess-suite-timing
Open

fix(reporter): expose setup/teardown projects to preprocessSuite#41731
Skn0tt wants to merge 6 commits into
microsoft:mainfrom
Skn0tt:skn0tt-preprocess-suite-timing

Conversation

@Skn0tt

@Skn0tt Skn0tt commented Jul 10, 2026

Copy link
Copy Markdown
Member

preprocessSuite() only exposed the top-level project suites, so a shard-balancing reporter couldn't measure the tests inside setup/teardown projects and weigh them.

This moves the dependency projects into the root suite before preprocessSuite runs, so reporters can see them. They're read-only - skip()/fixme()/fail()/exclude() throw on a dependency test or suite, since these always run in full. Identify them via testProject.dependencies and testProject.teardown.

Sharding is unchanged: still splits only the top-level projects, keeps every dependency test.

Closes #41708

@github-actions

This comment has been minimized.

Dropped the reverse() so setup/teardown projects keep the same order
in the root suite as before, avoiding a spurious UI mode filter reorder.
@github-actions

This comment has been minimized.

@Skn0tt Skn0tt marked this pull request as ready for review July 10, 2026 15:18
@Skn0tt Skn0tt requested a review from dgozman July 10, 2026 15:18
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread packages/playwright/src/common/test.ts Outdated
_fullProject: FullProjectInternal | undefined;
_fileId: string | undefined;
_preprocessing = false;
_isDependency = false;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we unify _isDependency and _preprocessing into a single enum? I'd like Suite to be as independent as possible from the environment around it.

// Create test groups for top-level projects.
const testGroups: TestGroup[] = [];
for (const projectSuite of rootSuite.suites) {
if (projectSuite._isDependency)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of relying on the flag we set on suites, let's make decisions based on the local variables in this method, e.g. projectClosure.get(project) === 'dependency'


// Update project suites, removing empty ones.
suiteUtils.filterTestsRemoveEmptySuites(rootSuite, test => testsInThisShard.has(test));
suiteUtils.filterTestsRemoveEmptySuites(rootSuite, test => test.parent._isInDependencyProject() || testsInThisShard.has(test));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, let's not rely on _isInDependencyProject().

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: af814592-e5ae-4edb-a8ef-dc73c2882097
@Skn0tt Skn0tt requested a review from dgozman July 13, 2026 12:20
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

8 flaky ⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:680 › screencast › should capture full viewport on hidpi `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:680 › screencast › should capture full viewport on hidpi `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/video.spec.ts:717 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/video.spec.ts:680 › screencast › should capture full viewport on hidpi `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/video.spec.ts:476 › screencast › should capture static page in persistent context @smoke `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/inspector/cli-codegen-3.spec.ts:255 › cli codegen › should generate frame locators (4) `@webkit-ubuntu-22.04-node20`

49541 passed, 1168 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

2 failed
❌ [chromium] › mcp/annotate.spec.ts:110 › should abort annotation when last screenshot is removed @mcp-windows-latest-chromium
❌ [firefox] › mcp/annotate.spec.ts:173 › user-initiated annotate downloads zip with feedback.md @mcp-macos-latest-firefox

7758 passed, 1249 skipped


Merge workflow run.

if (type !== 'dependency')
continue;
const dependencySuite = buildProjectSuite(project, projectSuites.get(project)!);
dependencySuite._preprocessMode = 'readonly';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Make sure to reset this to undefined.
  • I'd also mark top-level ones as editable here, and remove it from InternalReporter.preprocessSuite. I think that makes for a better separation of concerns.

const topLevelProjects = rootSuite.suites.filter(suite => !dependencyProjectIds.has(suite._fullProject!.id)).map(suite => suite._fullProject!);
const neededClosure = buildProjectsClosure(topLevelProjects);
for (const projectSuite of [...rootSuite.suites]) {
if (dependencyProjectIds.has(projectSuite._fullProject!.id) && !neededClosure.has(projectSuite._fullProject!))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems technically incorrect. Imagine I run npx playwright test setup.spec main.spec and then tests from main.spec are filtered out. This code will remove the setup.spec as well, while the intent was to include it. I guess we should only drop the projects that were added to projectClosure, but were missing in filteredProjectSuites.

Skn0tt and others added 3 commits July 14, 2026 07:57
Copilot-Session: af814592-e5ae-4edb-a8ef-dc73c2882097
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: af814592-e5ae-4edb-a8ef-dc73c2882097
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: af814592-e5ae-4edb-a8ef-dc73c2882097
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feedback on the new preprocessSuite API

2 participants