mirror of
https://github.com/microsoft/playwright.git
synced 2024-10-27 05:46:28 +03:00
parent
c37dfb379b
commit
050f26764e
@ -654,3 +654,19 @@ await context.AddInitScriptAsync(@"(storage => {
|
||||
}
|
||||
})('" + loadedSessionStorage + "')");
|
||||
```
|
||||
|
||||
### Avoid authentication in some tests
|
||||
* langs: js
|
||||
|
||||
You can reset storage state in a test file to avoid authentication that was set up for the whole project.
|
||||
|
||||
```js title="not-signed-in.spec.ts"
|
||||
import { test } from '@playwright/test';
|
||||
|
||||
// Reset storage state for this file to avoid being authenticated
|
||||
test.use({ storageState: { cookies: [], origins: [] } });
|
||||
|
||||
test('not signed in test', async ({ page }) => {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
@ -492,6 +492,21 @@ export default defineConfig({
|
||||
});
|
||||
```
|
||||
|
||||
**Details**
|
||||
|
||||
When storage state is set up in the config, it is possible to reset storage state for a file:
|
||||
|
||||
```js title="not-signed-in.spec.ts"
|
||||
import { test } from '@playwright/test';
|
||||
|
||||
// Reset storage state for this file to avoid being authenticated
|
||||
test.use({ storageState: { cookies: [], origins: [] } });
|
||||
|
||||
test('not signed in test', async ({ page }) => {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
## property: TestOptions.testIdAttribute
|
||||
* since: v1.27
|
||||
|
||||
|
16
packages/playwright-test/types/test.d.ts
vendored
16
packages/playwright-test/types/test.d.ts
vendored
@ -4012,6 +4012,22 @@ export interface PlaywrightTestOptions {
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* **Details**
|
||||
*
|
||||
* When storage state is set up in the config, it is possible to reset storage state for a file:
|
||||
*
|
||||
* ```js
|
||||
* // not-signed-in.spec.ts
|
||||
* import { test } from '@playwright/test';
|
||||
*
|
||||
* // Reset storage state for this file to avoid being authenticated
|
||||
* test.use({ storageState: { cookies: [], origins: [] } });
|
||||
*
|
||||
* test('not signed in test', async ({ page }) => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
storageState: StorageState | undefined;
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user