# playwrightProxy

Canonical: <https://test-proxy-recorder.dev/docs/reference/api/variables/playwrightproxy/>
Docs index: <https://test-proxy-recorder.dev/docs/> · All docs as one file: <https://test-proxy-recorder.dev/llms-full.txt>

---

> `const` **playwrightProxy**: `object`

Defined in: [playwright/index.ts:390](https://github.com/asmyshlyaev177/test-proxy-recorder/blob/d1bacb3b39a3cf6f7f5a5391a8201868e4629861/packages/test-proxy-recorder/src/playwright/index.ts#L390)

## Type Declaration

### before()

> **before**(`page`, `testInfo`, `mode`, `options?`): `Promise`\<`void`\>

Setup before test - sets the proxy mode and configures page with custom header
Automatically sets up page.on('close') handler for cleanup

#### Parameters

##### page

`Page`

Playwright page object

##### testInfo

[`PlaywrightTestInfo`](/docs/reference/api/type-aliases/playwrighttestinfo/)

Playwright test info object

##### mode

[`Mode`](/docs/reference/api/type-aliases/mode/)

The proxy mode to use for this test

##### options?

`number` \| `ClientSideRecordingOptions` & `object`

Optional configuration including timeout and client-side recording patterns

#### Returns

`Promise`\<`void`\>

### teardown()

> **teardown**(): `Promise`\<`void`\>

Global teardown — switches the proxy to transparent mode and redacts the
`.har` files Playwright wrote during the run.

HAR redaction happens here, not per-test, on purpose: Playwright flushes a
HAR when its context closes but does not await `context.on('close')`
listeners, so redacting there races the process exit and can truncate the
file. `globalTeardown` runs once, after every context has flushed, and IS
awaited — so it's the only reliable place to scrub HARs.

#### Returns

`Promise`\<`void`\>
