From 1b2cb1c7b2677a4d3d98e0f3bfd2337169aeffe2 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 25 Jul 2022 11:20:19 +0200 Subject: [PATCH] cherry-pick(#15901): fix(test-runner): multiple webServer types (#15916) SHA: 004cd9273c1ec7c5f0e304c3facc7adcb9f231b8 --- packages/playwright-test/types/test.d.ts | 2 +- tests/playwright-test/config.spec.ts | 26 ++++++++++++++++++++++++ utils/generate_types/overrides-test.d.ts | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) 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 | (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 extends TestConfig {