Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(test): show how to pass an httpCredentials array to test.use (#43110)

Lazizbek Ergashev3b5535e9f4b5
diff --git a/docs/src/test-api/class-testoptions.md b/docs/src/test-api/class-testoptions.md
index f4c3c1e936..ef35630c18 100644
--- a/docs/src/test-api/class-testoptions.md
+++ b/docs/src/test-api/class-testoptions.md
@@ -346,6 +346,17 @@ export default defineConfig({
});
```
+When passing an array of credentials to [`method: Test.use`], wrap it into an extra array, see [fixture options](../test-fixtures.md#fixtures-options).
+
+```js title="example.spec.ts"
+test.use({
+ httpCredentials: [[
+ { username: 'alice', password: 'alice-pass', origin: 'https://a.example.com' },
+ { username: 'bob', password: 'bob-pass', origin: 'https://b.example.com' },
+ ], { scope: 'test' }],
+});
+```
+
## property: TestOptions.ignoreHTTPSErrors = %%-context-option-ignorehttpserrors-%%
* since: v1.10
diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts
index ca74f02412..068ea455ab 100644
--- a/packages/playwright/types/test.d.ts
+++ b/packages/playwright/types/test.d.ts
@@ -7584,6 +7584,19 @@ export interface PlaywrightTestOptions {
* });
* ```
*
+ * When passing an array of credentials to [test.use(options)](https://playwright.dev/docs/api/class-test#test-use),
+ * wrap it into an extra array, see [fixture options](https://playwright.dev/docs/test-fixtures#fixtures-options).
+ *
+ * ```js
+ * // example.spec.ts
+ * test.use({
+ * httpCredentials: [[
+ * { username: 'alice', password: 'alice-pass', origin: 'https://a.example.com' },
+ * { username: 'bob', password: 'bob-pass', origin: 'https://b.example.com' },
+ * ], { scope: 'test' }],
+ * });
+ * ```
+ *
*/
httpCredentials: HTTPCredentials | HTTPCredentials[] | undefined;
/**