From 0b300f455cd2fe28265c116703ad0eab1991c021 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 2 Mar 2023 13:32:23 -0800 Subject: [PATCH] fix(test runner): empty dependency should not skip other projects (#21354) References #21270. --- .../playwright-test/src/runner/loadUtils.ts | 5 +- tests/playwright-test/deps.spec.ts | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) 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']); +});