fix(test runner): empty dependency should not skip other projects (#21354)

References #21270.
This commit is contained in:
Dmitry Gozman 2023-03-02 13:32:23 -08:00 committed by GitHub
parent b7dd226edd
commit 0b300f455c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 3 deletions

View File

@ -163,9 +163,8 @@ async function createProjectSuite(fileSuits: Suite[], project: FullProjectIntern
return grepMatcher(grepTitle) && (!options.cliTitleMatcher || options.cliTitleMatcher(grepTitle));
};
if (filterTestsRemoveEmptySuites(projectSuite, titleMatcher))
return projectSuite;
return null;
filterTestsRemoveEmptySuites(projectSuite, titleMatcher);
return projectSuite;
}
function createForbidOnlyErrors(onlyTestsAndSuites: (TestCase | Suite)[]): TestError[] {

View File

@ -330,3 +330,52 @@ test('should run dependency in each shard', async ({ runInlineTest }) => {
expect(result.outputLines).toEqual(['setup', 'test2']);
}
});
test('should run setup project with zero tests', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
projects: [
{ name: 'setup', testMatch: /not-matching/ },
{ name: 'real', dependencies: ['setup'] },
],
};`,
'test.spec.ts': `
import { test, expect } from '@playwright/test';
test('test', async ({}, testInfo) => {
console.log('\\n%%' + testInfo.project.name);
});
`,
}, { workers: 1 });
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
expect(result.outputLines).toEqual(['real']);
});
test('should run setup project with zero tests recursively', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
projects: [
{ name: 'A', testMatch: /a.spec/ },
{ name: 'B', testMatch: /not-matching/, dependencies: ['A'] },
{ name: 'C', testMatch: /c.spec/, dependencies: ['B'] },
],
};`,
'a.spec.ts': `
import { test, expect } from '@playwright/test';
test('test', async ({}, testInfo) => {
console.log('\\n%%' + testInfo.project.name);
});
`,
'c.spec.ts': `
import { test, expect } from '@playwright/test';
test('test', async ({}, testInfo) => {
console.log('\\n%%' + testInfo.project.name);
});
`,
}, { workers: 1, project: 'C' });
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(2);
expect(result.outputLines).toEqual(['A', 'C']);
});