fix(deps): --repeat-each should not apply to dependencies (#22858)

Fixes #21778.
This commit is contained in:
Dmitry Gozman 2023-05-05 16:59:39 -07:00 committed by GitHub
parent efad19b332
commit 03616e976e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

View File

@ -164,7 +164,9 @@ export class FullProjectInternal {
grep: takeFirst(projectConfig.grep, config.grep, defaultGrep),
grepInvert: takeFirst(projectConfig.grepInvert, config.grepInvert, null),
outputDir: takeFirst(configCLIOverrides.outputDir, pathResolve(configDir, projectConfig.outputDir), pathResolve(configDir, config.outputDir), path.join(throwawayArtifactsPath, 'test-results')),
repeatEach: takeFirst(configCLIOverrides.repeatEach, projectConfig.repeatEach, config.repeatEach, 1),
// Note: we either apply the cli override for repeatEach or not, depending on whether the
// project is top-level vs dependency. See collectProjectsAndTestFiles in loadUtils.
repeatEach: takeFirst(projectConfig.repeatEach, config.repeatEach, 1),
retries: takeFirst(configCLIOverrides.retries, projectConfig.retries, config.retries, 0),
metadata: takeFirst(projectConfig.metadata, config.metadata, undefined),
name: takeFirst(projectConfig.name, config.name, ''),

View File

@ -73,6 +73,12 @@ export async function collectProjectsAndTestFiles(testRun: TestRun, additionalFi
}
}
// Apply overrides that are only applicable to top-level projects.
for (const [project, type] of projectClosure) {
if (type === 'top-level')
project.project.repeatEach = project.fullConfig.configCLIOverrides.repeatEach ?? project.project.repeatEach;
}
testRun.projects = [...filesToRunByProject.keys()];
testRun.projectFiles = filesToRunByProject;
testRun.projectType = projectClosure;

View File

@ -559,3 +559,25 @@ test('should complain about teardown used multiple times', async ({ runInlineTes
expect(result.exitCode).toBe(1);
expect(result.output).toContain(`Project C can not be designated as teardown to multiple projects (A and B)`);
});
test('should only apply --repeat-each to top-level', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
projects: [
{ name: 'A' },
{ name: 'B', dependencies: ['A'] },
{ name: 'C', dependencies: ['A'] },
],
};`,
'test.spec.ts': `
import { test, expect } from '@playwright/test';
test('test', async ({}, testInfo) => {
console.log('\\n%%' + testInfo.project.name);
});
`,
}, { 'workers': 1, 'repeat-each': 2 });
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(5);
expect(result.outputLines).toEqual(['A', 'B', 'B', 'C', 'C']);
});