make it an enum
This commit is contained in:
parent
b0cce73542
commit
fe608159ac
|
|
@ -679,7 +679,7 @@ export default defineConfig({
|
|||
|
||||
## property: TestOptions.mockingProxy
|
||||
* since: v1.51
|
||||
- type: <[boolean]> Enables the mocking proxy. Playwright will inject the proxy URL into all outgoing requests under the `x-playwright-proxy` header.
|
||||
- type: <[MockingProxyMode]<"off"|"inject-via-header">> Enables the mocking proxy. Playwright will inject the proxy URL into all outgoing requests under the `x-playwright-proxy` header.
|
||||
|
||||
**Usage**
|
||||
|
||||
|
|
@ -688,7 +688,7 @@ import { defineConfig } from '@playwright/test';
|
|||
|
||||
export default defineConfig({
|
||||
use: {
|
||||
mockingProxy: true
|
||||
mockingProxy: 'inject-via-header'
|
||||
},
|
||||
});
|
||||
```
|
||||
|
|
@ -74,8 +74,8 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
|
|||
return (channel as any)._object;
|
||||
}
|
||||
|
||||
async _startMockingProxy(requestContextOptions: NewContextOptions) {
|
||||
const requestContext = await this.request._newContext(requestContextOptions, this._connection.localUtils()._channel);
|
||||
async _startMockingProxy() {
|
||||
const requestContext = await this.request._newContext(undefined, this._connection.localUtils()._channel);
|
||||
const { mockingProxy } = await this._connection.localUtils()._channel.newMockingProxy({ requestContext: requestContext._channel });
|
||||
return (mockingProxy as any)._object;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
|
|||
}, { scope: 'worker', timeout: 0 }],
|
||||
|
||||
_mockingProxy: [async ({ mockingProxy: mockingProxyOption, playwright }, use) => {
|
||||
if (!mockingProxyOption)
|
||||
if (mockingProxyOption !== 'inject-via-header')
|
||||
return await use(undefined);
|
||||
const mockingProxy = await (playwright as PlaywrightImpl)._startMockingProxy();
|
||||
await use(mockingProxy);
|
||||
|
|
|
|||
5
packages/playwright/types/test.d.ts
vendored
5
packages/playwright/types/test.d.ts
vendored
|
|
@ -6166,18 +6166,19 @@ export interface PlaywrightWorkerOptions {
|
|||
*
|
||||
* export default defineConfig({
|
||||
* use: {
|
||||
* mockingProxy: true
|
||||
* mockingProxy: 'inject-via-header'
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
mockingProxy: boolean | undefined;
|
||||
mockingProxy: MockingProxyMode | undefined;
|
||||
}
|
||||
|
||||
export type ScreenshotMode = 'off' | 'on' | 'only-on-failure' | 'on-first-failure';
|
||||
export type TraceMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry' | 'on-all-retries' | 'retain-on-first-failure';
|
||||
export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry';
|
||||
export type MockingProxyMode = 'off' | 'inject-via-header';
|
||||
|
||||
/**
|
||||
* Playwright Test provides many options to configure test environment,
|
||||
|
|
|
|||
3
utils/generate_types/overrides-test.d.ts
vendored
3
utils/generate_types/overrides-test.d.ts
vendored
|
|
@ -236,12 +236,13 @@ export interface PlaywrightWorkerOptions {
|
|||
screenshot: ScreenshotMode | { mode: ScreenshotMode } & Pick<PageScreenshotOptions, 'fullPage' | 'omitBackground'>;
|
||||
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean, screenshots?: boolean, sources?: boolean, attachments?: boolean };
|
||||
video: VideoMode | /** deprecated */ 'retry-with-video' | { mode: VideoMode, size?: ViewportSize };
|
||||
mockingProxy: boolean | undefined;
|
||||
mockingProxy: MockingProxyMode | undefined;
|
||||
}
|
||||
|
||||
export type ScreenshotMode = 'off' | 'on' | 'only-on-failure' | 'on-first-failure';
|
||||
export type TraceMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry' | 'on-all-retries' | 'retain-on-first-failure';
|
||||
export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry';
|
||||
export type MockingProxyMode = 'off' | 'inject-via-header';
|
||||
|
||||
export interface PlaywrightTestOptions {
|
||||
acceptDownloads: boolean;
|
||||
|
|
|
|||
Loading…
Reference in a new issue