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".
This commit is contained in:
Dmitry Gozman 2023-11-17 13:36:50 -08:00 committed by GitHub
parent 11bf96fe98
commit 62d4c3fe02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -48,6 +48,9 @@ export const defineConfig = (...configs: any[]) => {
]
};
if (!result.projects && !config.projects)
continue;
const projectOverrides = new Map<string, any>();
for (const project of config.projects || [])
projectOverrides.set(project.name, project);

View File

@ -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';