From 738d5e5b3eabf6151c2ad7e4ac4fe62adef87fed Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Wed, 18 May 2022 12:03:47 -0700 Subject: [PATCH] chore: pass fixture defaults different from falsy (#14237) --- packages/playwright-test/src/index.ts | 10 +++++----- tests/playwright-test/playwright.spec.ts | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/playwright-test/src/index.ts b/packages/playwright-test/src/index.ts index 76e31d5b94..083df68454 100644 --- a/packages/playwright-test/src/index.ts +++ b/packages/playwright-test/src/index.ts @@ -64,7 +64,7 @@ export const test = _baseTest.extend({ await use(require('playwright-core')); } }, { scope: 'worker' } ], - headless: [ undefined, { scope: 'worker', option: true } ], + headless: [ true, { scope: 'worker', option: true } ], channel: [ undefined, { scope: 'worker', option: true } ], launchOptions: [ {}, { scope: 'worker', option: true } ], connectOptions: [ undefined, { scope: 'worker', option: true } ], @@ -135,7 +135,7 @@ export const test = _baseTest.extend({ await browser.close(); }, { scope: 'worker' } ], - acceptDownloads: [ undefined, { option: true } ], + acceptDownloads: [ true, { option: true } ], bypassCSP: [ undefined, { option: true } ], colorScheme: [ undefined, { option: true } ], deviceScaleFactor: [ undefined, { option: true } ], @@ -145,7 +145,7 @@ export const test = _baseTest.extend({ httpCredentials: [ undefined, { option: true } ], ignoreHTTPSErrors: [ undefined, { option: true } ], isMobile: [ undefined, { option: true } ], - javaScriptEnabled: [ undefined, { option: true } ], + javaScriptEnabled: [ true, { option: true } ], locale: [ 'en-US', { option: true } ], offline: [ undefined, { option: true } ], permissions: [ undefined, { option: true } ], @@ -154,8 +154,8 @@ export const test = _baseTest.extend({ timezoneId: [ undefined, { option: true } ], userAgent: [ undefined, { option: true } ], viewport: [ { width: 1280, height: 720 }, { option: true } ], - actionTimeout: [ undefined, { option: true } ], - navigationTimeout: [ undefined, { option: true } ], + actionTimeout: [ 0, { option: true } ], + navigationTimeout: [ 0, { option: true } ], baseURL: [ async ({ }, use) => { await use(process.env.PLAYWRIGHT_TEST_BASE_URL); }, { option: true } ], diff --git a/tests/playwright-test/playwright.spec.ts b/tests/playwright-test/playwright.spec.ts index c93bd4cdde..0915e5ced3 100644 --- a/tests/playwright-test/playwright.spec.ts +++ b/tests/playwright-test/playwright.spec.ts @@ -582,3 +582,23 @@ test('should work with video.path() throwing', async ({ runInlineTest }, testInf const video = fs.readdirSync(dir).find(file => file.endsWith('webm')); expect(video).toBeTruthy(); }); + +test('should pass fixture defaults to tests', async ({ runInlineTest }) => { + const result = await runInlineTest({ + 'playwright.config.js': ` + module.exports = {}; + `, + 'a.test.ts': ` + const { test } = pwt; + test('pass', async ({ acceptDownloads, actionTimeout, headless, javaScriptEnabled, navigationTimeout }) => { + expect(acceptDownloads).toBe(true); + expect(actionTimeout).toBe(0); + expect(headless).toBe(true); + expect(javaScriptEnabled).toBe(true); + expect(navigationTimeout).toBe(0); + }); + `, + }, { workers: 1 }); + expect(result.exitCode).toBe(0); + expect(result.passed).toBe(1); +});