docs: add proxy example to the API testing guide (#28959)

Fixes https://github.com/microsoft/playwright/issues/28940
This commit is contained in:
Yury Semikhatsky 2024-01-11 13:39:35 -08:00 committed by GitHub
parent c5097a500d
commit b392c2d392
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,6 +48,24 @@ export default defineConfig({
}); });
``` ```
**Proxy configuration**
If your tests need to run behind a proxy, you can specify this in the config and the `request` fixture
will pick it up automatically:
```js title="playwright.config.ts"
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
proxy: {
server: 'http://my-proxy:8080',
username: 'user',
password: 'secret'
},
}
});
```
### Writing tests ### Writing tests
Playwright Test comes with the built-in `request` fixture that respects configuration options like `baseURL` or `extraHTTPHeaders` we specified and is ready to send some requests. Playwright Test comes with the built-in `request` fixture that respects configuration options like `baseURL` or `extraHTTPHeaders` we specified and is ready to send some requests.