Skip to content

Commit

Permalink
chore: pass fixture defaults different from falsy (#14237)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored May 18, 2022
1 parent 50b2d4a commit 738d5e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/playwright-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } ],
Expand Down Expand Up @@ -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 } ],
Expand All @@ -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 } ],
Expand All @@ -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 } ],
Expand Down
20 changes: 20 additions & 0 deletions tests/playwright-test/playwright.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 738d5e5

Please sign in to comment.