feat(test-runner): allow parametrized tests that don't extend base (#9301)

This commit is contained in:
Pavel Feldman 2021-10-04 16:16:33 -08:00 committed by GitHub
parent 6e803f7186
commit f63af830de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 2 deletions

View File

@ -182,3 +182,29 @@ test('config should allow void/empty options', async ({ runTSC }) => {
});
expect(result.exitCode).toBe(0);
});
test('config should allow ExtraUseOptions', async ({ runTSC }) => {
const result = await runTSC({
'playwright.config.ts': `
const configs: pwt.Config[] = [];
configs.push({ use: { myParam: 'text' }});
`,
'extraUseOptions.d.ts': `
export {};
declare global {
namespace PlaywrightTest {
export interface ExtraUseOptions {
myParam: string
}
}
}
`,
'a.spec.ts': `
const { test } = pwt;
test('my test', async ({ myParam }) => {
console.log(myParam);
});
`
});
expect(result.exitCode).toBe(0);
});

2
types/test.d.ts vendored
View File

@ -2444,7 +2444,7 @@ export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry' |
* ```
*
*/
export interface PlaywrightTestOptions {
export interface PlaywrightTestOptions extends PlaywrightTest.ExtraUseOptions {
/**
* Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
*/

View File

@ -166,4 +166,11 @@ declare global {
}
}
declare global {
namespace PlaywrightTest {
export interface ExtraUseOptions {
}
}
}
export { };

View File

@ -298,7 +298,7 @@ export interface PlaywrightWorkerOptions {
export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry' | /** deprecated */ 'retry-with-video';
export interface PlaywrightTestOptions {
export interface PlaywrightTestOptions extends PlaywrightTest.ExtraUseOptions {
acceptDownloads: boolean | undefined;
bypassCSP: boolean | undefined;
colorScheme: ColorScheme | undefined;