[Feature]: Schedule projects by their own dependencies instead of global phases

Open
#44,276 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript

Research direction

Start by reading createPhasesTask and createRunTestsTask in lib/runner/index.js, focusing on the phase loop for (const { dispatcher, projects } of testRun.phases). Map how dependencies, workers, fullyParallel, teardown and maxFailures flow into that loop, and confirm where metadata.actualWorkers is computed. This is a scheduling redesign that needs maintainer agreement on default versus opt-in before any patch; a first step is a written design plus a failing scenario like the example config.

Written by the indexing model from the issue text.

Description

🚀 Feature Request

When a config uses project dependencies, the runner groups projects into phases and runs them strictly one after another. A project only starts after every project in the previous phase has finished, including projects it doesn't depend on.

So a project whose own dependencies finished long ago can sit waiting for slow, unrelated projects, with most workers idle.

The cause is in createPhasesTask (lib/runner/index.js, 1.64.0). It builds phases from a topological sort, and createRunTestsTask runs them in order (for (const { dispatcher, projects } of testRun.phases)).

Proposal: schedule projects from the dependency graph instead of from phases.

  1. A project's test groups become eligible as soon as all of its own dependencies have finished successfully, or are skipped as they are today when a dependency fails.
  2. Eligible test groups from all ready projects share the global worker pool. Project-level workers limits and fullyParallel behave as they do now.
  3. teardown keeps its current meaning: a teardown project runs after its setup and everything that depends on that setup.
  4. maxFailures / ignoreMaxFailures keep their current behaviour for setup and teardown projects.

If changing the default is too risky, an opt-in setting would also work:

export default defineConfig({
  projectScheduling: 'graph', // default: 'phases' (current behaviour)
});

Note: metadata.actualWorkers is currently the largest number of concurrent test groups in any single phase. With graph scheduling, it would need to be computed over the whole run.

Example

Minimal repro:

// playwright.config.ts
export default defineConfig({
  workers: 4,
  projects: [
    { name: 'setup-fast', testMatch: /fast\.setup\.ts/ },          // ~5s
    { name: 'independent', testMatch: /independent\.spec\.ts/ },   // ~5 min, no dependencies
    { name: 'dependent', dependencies: ['setup-fast'],
      testMatch: /dependent\.spec\.ts/ },                          // ~5 min
  ],
});
npx playwright test --project=independent --project=dependent
  • Expected: dependent starts about 5 seconds in, when setup-fast finishes. Both projects run in parallel, so the whole run takes about 5 minutes.
  • Actual: dependent waits for independent to finish. The run takes about 10 minutes, and workers sit idle for the first half.

With graph scheduling, the config stays exactly the same; only the start times change.

Motivation

Project dependencies are the recommended replacement for globalSetup, and the usual pattern is one setup project per isolated data set, feeding parallel test projects. Phase-based scheduling undercuts that parallelism.

Our real case: 8 test batches, each with workers: 1 (they share seeded data), and workers: 8 overall. Six batches each depend on their own setup project; two have no dependencies. Phase 1 holds the six setups plus the two independent batches. Once the setups finish (2 to 4 minutes), phase 1 is down to two running workers, while six batches stay blocked even though their setups passed. Six of the eight workers are idle for most of the run.

The only workaround is to give every project an artificial no-op dependency so they all fall into the same phase. That's a hack that delays the projects that had no dependencies and makes the config harder to follow.

Scheduling by the dependency graph would make the configured worker count a real number, cut wall-clock time for suites that use setup projects, and make project dependencies behave the way most users already assume they do.

Dominant language
TypeScript
Stars
100k
Forks
6.9k
Avg merge
16h 8m
Merged PRs (30d)
281

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/playwright

All issues in microsoft/playwright

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.