From 62d4c3fe0261c7fad813746f93d617ef07b272b0 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 17 Nov 2023 13:36:50 -0800 Subject: [PATCH] fix(defineConfig): do not add an empty project list to project-less configs (#28224) Otherwise, merging two configs without `projects` property will create a config with an empty project list, which is semantically different and always leads to "No tests found". --- packages/playwright/src/common/configLoader.ts | 3 +++ tests/playwright-test/config.spec.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/playwright/src/common/configLoader.ts b/packages/playwright/src/common/configLoader.ts index 4d72ed73a0..9d648ed0ea 100644 --- a/packages/playwright/src/common/configLoader.ts +++ b/packages/playwright/src/common/configLoader.ts @@ -48,6 +48,9 @@ export const defineConfig = (...configs: any[]) => { ] }; + if (!result.projects && !config.projects) + continue; + const projectOverrides = new Map(); for (const project of config.projects || []) projectOverrides.set(project.name, project); diff --git a/tests/playwright-test/config.spec.ts b/tests/playwright-test/config.spec.ts index bddbde5f57..fb2f1888d2 100644 --- a/tests/playwright-test/config.spec.ts +++ b/tests/playwright-test/config.spec.ts @@ -546,6 +546,9 @@ test('should merge configs', async ({ runInlineTest }) => { command: 'echo 123', }] })); + + // Should not add an empty project list. + expect(defineConfig({}, {}).projects).toBeUndefined(); `, 'a.test.ts': ` import { test } from '@playwright/test';