Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Dmitry Gozman0b300f455cd2
diff --git a/packages/playwright-test/src/runner/loadUtils.ts b/packages/playwright-test/src/runner/loadUtils.ts
index 4dc78faa64..995d0efcac 100644
--- a/packages/playwright-test/src/runner/loadUtils.ts
+++ b/packages/playwright-test/src/runner/loadUtils.ts
@@ -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[] {
diff --git a/tests/playwright-test/deps.spec.ts b/tests/playwright-test/deps.spec.ts
index 7e4829bfa5..eefc4b422a 100644
--- a/tests/playwright-test/deps.spec.ts
+++ b/tests/playwright-test/deps.spec.ts
@@ -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']);
+});