Skip to content

fix(runner): incorporate set project worker count into status messages #35717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/playwright/src/runner/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function createPhasesTask(): Task<TestRun> {
const projectSuite = projectToSuite.get(project)!;
const testGroups = createTestGroups(projectSuite, testRun.config.config.workers);
phase.projects.push({ project, projectSuite, testGroups });
testGroupsInPhase += testGroups.length;
testGroupsInPhase += Math.min(project.workers ?? Number.MAX_SAFE_INTEGER, testGroups.length);
}
debug('pw:test:task')(`created phase #${testRun.phases.length} with ${phase.projects.map(p => p.project.project.name).sort()} projects, ${testGroupsInPhase} testGroups`);
maxConcurrentTestGroups = Math.max(maxConcurrentTestGroups, testGroupsInPhase);
Expand Down
49 changes: 49 additions & 0 deletions tests/playwright-test/test-parallel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,52 @@ test('parallel mode should minimize running beforeAll/afterAll hooks 2', async (
expect(countTimes(result.output, '%%beforeAll')).toBe(2);
expect(countTimes(result.output, '%%afterAll')).toBe(2);
});

test('parallel mode should display worker count taking project workers into account', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
export default {
workers: 10,
fullyParallel: true,
projects: [
{ name: 'project1', workers: 3 },
],
};
`,
'a.test.ts': `
import { test, expect } from '@playwright/test';
test('test1', () => {});
test('test2', () => {});
test('test3', () => {});
test('test4', () => {});
`,
}, { workers: 10 });
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(4);
expect(result.output).toContain('Running 4 tests using 3 workers');

// Multiple parallel projects
const result2 = await runInlineTest({
'playwright.config.ts': `
export default {
workers: 12,
fullyParallel: true,
projects: [
{ name: 'project1', workers: 3 },
{ name: 'project2', workers: 4 },
{ name: 'project3', workers: 4 },
],
};
`,
'a.test.ts': `
import { test, expect } from '@playwright/test';
test('test1', () => {});
test('test2', () => {});
test('test3', () => {});
test('test4', () => {});
`,
}, { workers: 12 });
expect(result2.exitCode).toBe(0);
expect(result2.passed).toBe(12);
expect(result2.output).toContain('Running 12 tests using 11 workers');
});
Loading