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): multiple webServer types (#15901)

Max Schmitt004cd9273c1e
diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts
index ac6aba285d..e5f30330a9 100644
--- a/packages/playwright-test/types/test.d.ts
+++ b/packages/playwright-test/types/test.d.ts
@@ -487,7 +487,7 @@ interface TestConfig {
* ```
*
*/
- webServer?: TestConfigWebServer;
+ webServer?: TestConfigWebServer | TestConfigWebServer[];
/**
* Configuration for the `expect` assertion library. Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts).
*
diff --git a/tests/playwright-test/config.spec.ts b/tests/playwright-test/config.spec.ts
index 21cd4b61c9..6ddc58f94b 100644
--- a/tests/playwright-test/config.spec.ts
+++ b/tests/playwright-test/config.spec.ts
@@ -391,3 +391,29 @@ test('should work with undefined values and base', async ({ runInlineTest }) =>
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
});
+
+test('should have correct types for the config', async ({ runTSC }) => {
+ const result = await runTSC({
+ 'playwright.config.ts': `
+ import type { PlaywrightTestConfig } from '@playwright/test';
+
+ const config: PlaywrightTestConfig = {
+ webServer: [
+ {
+ command: 'echo 123',
+ env: { PORT: '123' },
+ port: 123,
+ },
+ {
+ command: 'echo 123',
+ env: { NODE_ENV: 'test' },
+ port: 8082,
+ },
+ ],
+ };
+
+ export default config;
+ `
+ });
+ expect(result.exitCode).toBe(0);
+});
diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts
index ca0bb5f9ca..9b8c09bfd1 100644
--- a/utils/generate_types/overrides-test.d.ts
+++ b/utils/generate_types/overrides-test.d.ts
@@ -58,7 +58,7 @@ type LiteralUnion<T extends U, U = string> = T | (U & { zz_IGNORE_ME?: never });
interface TestConfig {
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[];
- webServer?: TestConfigWebServer;
+ webServer?: TestConfigWebServer | TestConfigWebServer[];
}
export interface Config<TestArgs = {}, WorkerArgs = {}> extends TestConfig {