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): restore `--headed` flag (#13872)

Dmitry Gozmand87de8c52c95
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': `