Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: pass fixture defaults different from falsy (#14237)

Pavel Feldman738d5e5b3eab
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<TestFixtures, WorkerFixtures>({
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<TestFixtures, WorkerFixtures>({
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<TestFixtures, WorkerFixtures>({
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<TestFixtures, WorkerFixtures>({
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);
+});