From d87de8c52c95efcb1fd932dc4bb124939edfb1e0 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Mon, 2 May 2022 16:55:14 +0100 Subject: [PATCH] fix(test runner): restore `--headed` flag (#13872) --- packages/playwright-test/src/loader.ts | 1 + tests/playwright-test/playwright.spec.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/playwright-test/src/loader.ts b/packages/playwright-test/src/loader.ts index 1323ef8c15..cb8611c90a 100644 --- a/packages/playwright-test/src/loader.ts +++ b/packages/playwright-test/src/loader.ts @@ -251,6 +251,7 @@ export class Loader { projectConfig.repeatEach = takeFirst(this._configCLIOverrides.repeatEach, projectConfig.repeatEach); projectConfig.retries = takeFirst(this._configCLIOverrides.retries, projectConfig.retries); projectConfig.timeout = takeFirst(this._configCLIOverrides.timeout, projectConfig.timeout); + projectConfig.use = mergeObjects(projectConfig.use, this._configCLIOverrides.use); } private _resolveProject(config: Config, projectConfig: Project, throwawayArtifactsPath: string): FullProjectInternal { diff --git a/tests/playwright-test/playwright.spec.ts b/tests/playwright-test/playwright.spec.ts index 59cff943cf..c93bd4cdde 100644 --- a/tests/playwright-test/playwright.spec.ts +++ b/tests/playwright-test/playwright.spec.ts @@ -121,6 +121,25 @@ test('should complain with projects and --browser', async ({ runInlineTest }) => expect(result.output).toContain('Cannot use --browser option when configuration file defines projects'); }); +test('should override any headless option with --headed', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'playwright.config.ts': ` + module.exports = { projects: [ + { name: 'a', use: { headless: true } } + ] }; + `, + 'a.test.ts': ` + const { test } = pwt; + test('example', async ({ page }) => { + expect(await page.evaluate(() => navigator.userAgent)).not.toContain('Headless'); + }); + `, + }, { workers: 1, headed: true }); + expect(result.exitCode).toBe(0); + expect(result.passed).toBe(1); +}); + + test('should not override use:browserName without projects', async ({ runInlineTest }) => { const result = await runInlineTest({ 'playwright.config.ts': `