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

This commit is contained in:
Pavel Feldman 2022-05-18 12:03:47 -07:00 committed by GitHub
parent 50b2d4aabe
commit 738d5e5b3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 5 deletions

View File

@ -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 } ],

View File

@ -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);
});