add config resolution
This commit is contained in:
parent
41fba1a959
commit
10681d401c
|
|
@ -140,6 +140,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
||||||
permissions: [({ contextOptions }, use) => use(contextOptions.permissions), { option: true }],
|
permissions: [({ contextOptions }, use) => use(contextOptions.permissions), { option: true }],
|
||||||
proxy: [({ contextOptions }, use) => use(contextOptions.proxy), { option: true }],
|
proxy: [({ contextOptions }, use) => use(contextOptions.proxy), { option: true }],
|
||||||
storageState: [({ contextOptions }, use) => use(contextOptions.storageState), { option: true }],
|
storageState: [({ contextOptions }, use) => use(contextOptions.storageState), { option: true }],
|
||||||
|
clientCertificates: [({ contextOptions }, use) => use(contextOptions.clientCertificates), { option: true }],
|
||||||
timezoneId: [({ contextOptions }, use) => use(contextOptions.timezoneId), { option: true }],
|
timezoneId: [({ contextOptions }, use) => use(contextOptions.timezoneId), { option: true }],
|
||||||
userAgent: [({ contextOptions }, use) => use(contextOptions.userAgent), { option: true }],
|
userAgent: [({ contextOptions }, use) => use(contextOptions.userAgent), { option: true }],
|
||||||
viewport: [({ contextOptions }, use) => use(contextOptions.viewport === undefined ? { width: 1280, height: 720 } : contextOptions.viewport), { option: true }],
|
viewport: [({ contextOptions }, use) => use(contextOptions.viewport === undefined ? { width: 1280, height: 720 } : contextOptions.viewport), { option: true }],
|
||||||
|
|
@ -155,6 +156,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
||||||
_combinedContextOptions: [async ({
|
_combinedContextOptions: [async ({
|
||||||
acceptDownloads,
|
acceptDownloads,
|
||||||
bypassCSP,
|
bypassCSP,
|
||||||
|
clientCertificates,
|
||||||
colorScheme,
|
colorScheme,
|
||||||
deviceScaleFactor,
|
deviceScaleFactor,
|
||||||
extraHTTPHeaders,
|
extraHTTPHeaders,
|
||||||
|
|
@ -209,6 +211,8 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
||||||
options.proxy = proxy;
|
options.proxy = proxy;
|
||||||
if (storageState !== undefined)
|
if (storageState !== undefined)
|
||||||
options.storageState = storageState;
|
options.storageState = storageState;
|
||||||
|
if (clientCertificates?.length)
|
||||||
|
options.clientCertificates = resolveClientCerticates(clientCertificates);
|
||||||
if (timezoneId !== undefined)
|
if (timezoneId !== undefined)
|
||||||
options.timezoneId = timezoneId;
|
options.timezoneId = timezoneId;
|
||||||
if (userAgent !== undefined)
|
if (userAgent !== undefined)
|
||||||
|
|
@ -416,6 +420,28 @@ function attachConnectedHeaderIfNeeded(testInfo: TestInfo, browser: Browser | nu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveFileToConfig(file: string | undefined) {
|
||||||
|
const config = test.info().config.configFile;
|
||||||
|
if (!config || !file)
|
||||||
|
return file;
|
||||||
|
if (!path.isAbsolute(file))
|
||||||
|
return path.resolve(path.dirname(config), file);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientCertificates = NonNullable<PlaywrightTestOptions['clientCertificates']>;
|
||||||
|
|
||||||
|
function resolveClientCerticates(clientCertificates: ClientCertificates): ClientCertificates {
|
||||||
|
for (const { certs } of clientCertificates) {
|
||||||
|
for (const cert of certs) {
|
||||||
|
cert.certPath = resolveFileToConfig(cert.certPath);
|
||||||
|
cert.keyPath = resolveFileToConfig(cert.keyPath);
|
||||||
|
cert.pfxPath = resolveFileToConfig(cert.pfxPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return clientCertificates;
|
||||||
|
}
|
||||||
|
|
||||||
const kTracingStarted = Symbol('kTracingStarted');
|
const kTracingStarted = Symbol('kTracingStarted');
|
||||||
const kIsReusedContext = Symbol('kReusedContext');
|
const kIsReusedContext = Symbol('kReusedContext');
|
||||||
|
|
||||||
|
|
|
||||||
2
packages/playwright/types/test.d.ts
vendored
2
packages/playwright/types/test.d.ts
vendored
|
|
@ -5239,7 +5239,7 @@ export interface PlaywrightTestOptions {
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
clientCertificates: ClientCertificate[];
|
clientCertificates: ClientCertificate[] | undefined;
|
||||||
/**
|
/**
|
||||||
* Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about
|
* Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about
|
||||||
* [emulating devices with device scale factor](https://playwright.dev/docs/emulation#devices).
|
* [emulating devices with device scale factor](https://playwright.dev/docs/emulation#devices).
|
||||||
|
|
|
||||||
2
utils/generate_types/overrides-test.d.ts
vendored
2
utils/generate_types/overrides-test.d.ts
vendored
|
|
@ -210,7 +210,7 @@ export interface PlaywrightTestOptions {
|
||||||
acceptDownloads: boolean;
|
acceptDownloads: boolean;
|
||||||
bypassCSP: boolean;
|
bypassCSP: boolean;
|
||||||
colorScheme: ColorScheme;
|
colorScheme: ColorScheme;
|
||||||
clientCertificates: ClientCertificate[];
|
clientCertificates: ClientCertificate[] | undefined;
|
||||||
deviceScaleFactor: number | undefined;
|
deviceScaleFactor: number | undefined;
|
||||||
extraHTTPHeaders: ExtraHTTPHeaders | undefined;
|
extraHTTPHeaders: ExtraHTTPHeaders | undefined;
|
||||||
geolocation: Geolocation | undefined;
|
geolocation: Geolocation | undefined;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue