Skip to content

[pull] main from microsoft:main #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/src/test-api/class-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ test('Safari-only test 2', async ({ page }) => {
});
```

You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We recommend using `test.skip(title, body)` instead.
You can also call `test.skip()` without arguments inside the test body to always skip the test. However, we recommend using `test.skip(title, body)` instead.

```js
import { test, expect } from '@playwright/test';
Expand Down Expand Up @@ -1511,13 +1511,13 @@ Test body that takes one or two arguments: an object with fixtures and optional
* since: v1.10
- `condition` ?<[boolean]>

Test is marked as "should fail" when the condition is `true`.
Test is marked as "skipped" when the condition is `true`.

### param: Test.skip.callback
* since: v1.10
- `callback` ?<[function]\([Fixtures]\):[boolean]>

A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as "should fail" when the return value is `true`.
A function that returns whether to mark as "skipped", based on test fixtures. Test or tests are marked as "skipped" when the return value is `true`.

### param: Test.skip.description
* since: v1.10
Expand Down
4 changes: 4 additions & 0 deletions packages/playwright-core/src/server/browserContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Debugger } from './debugger';
import { DialogManager } from './dialog';
import { BrowserContextAPIRequestContext } from './fetch';
import { mkdirIfNeeded } from './utils/fileUtils';
import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
import { HarRecorder } from './har/harRecorder';
import { helper } from './helper';
import { SdkObject } from './instrumentation';
Expand Down Expand Up @@ -644,6 +645,9 @@ export abstract class BrowserContext extends SdkObject {
}
await page.close();
}
} catch (error) {
rewriteErrorMessage(error, `Error setting storage state:\n` + error.message);
throw error;
} finally {
this._settingStorageState = false;
}
Expand Down
40 changes: 20 additions & 20 deletions packages/playwright/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4186,7 +4186,7 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* });
* ```
*
* You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We
* You can also call `test.skip()` without arguments inside the test body to always skip the test. However, we
* recommend using `test.skip(title, body)` instead.
*
* ```js
Expand All @@ -4203,9 +4203,9 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* description.
* @param body Test body that takes one or two arguments: an object with fixtures and optional
* [TestInfo](https://playwright.dev/docs/api/class-testinfo).
* @param condition Test is marked as "should fail" when the condition is `true`.
* @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as
* "should fail" when the return value is `true`.
* @param condition Test is marked as "skipped" when the condition is `true`.
* @param callback A function that returns whether to mark as "skipped", based on test fixtures. Test or tests are marked as "skipped"
* when the return value is `true`.
* @param description Optional description that will be reflected in a test report.
*/
skip(title: string, body: TestBody<TestArgs & WorkerArgs>): void;
Expand Down Expand Up @@ -4267,7 +4267,7 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* });
* ```
*
* You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We
* You can also call `test.skip()` without arguments inside the test body to always skip the test. However, we
* recommend using `test.skip(title, body)` instead.
*
* ```js
Expand All @@ -4284,9 +4284,9 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* description.
* @param body Test body that takes one or two arguments: an object with fixtures and optional
* [TestInfo](https://playwright.dev/docs/api/class-testinfo).
* @param condition Test is marked as "should fail" when the condition is `true`.
* @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as
* "should fail" when the return value is `true`.
* @param condition Test is marked as "skipped" when the condition is `true`.
* @param callback A function that returns whether to mark as "skipped", based on test fixtures. Test or tests are marked as "skipped"
* when the return value is `true`.
* @param description Optional description that will be reflected in a test report.
*/
skip(title: string, details: TestDetails, body: TestBody<TestArgs & WorkerArgs>): void;
Expand Down Expand Up @@ -4348,7 +4348,7 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* });
* ```
*
* You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We
* You can also call `test.skip()` without arguments inside the test body to always skip the test. However, we
* recommend using `test.skip(title, body)` instead.
*
* ```js
Expand All @@ -4365,9 +4365,9 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* description.
* @param body Test body that takes one or two arguments: an object with fixtures and optional
* [TestInfo](https://playwright.dev/docs/api/class-testinfo).
* @param condition Test is marked as "should fail" when the condition is `true`.
* @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as
* "should fail" when the return value is `true`.
* @param condition Test is marked as "skipped" when the condition is `true`.
* @param callback A function that returns whether to mark as "skipped", based on test fixtures. Test or tests are marked as "skipped"
* when the return value is `true`.
* @param description Optional description that will be reflected in a test report.
*/
skip(): void;
Expand Down Expand Up @@ -4429,7 +4429,7 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* });
* ```
*
* You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We
* You can also call `test.skip()` without arguments inside the test body to always skip the test. However, we
* recommend using `test.skip(title, body)` instead.
*
* ```js
Expand All @@ -4446,9 +4446,9 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* description.
* @param body Test body that takes one or two arguments: an object with fixtures and optional
* [TestInfo](https://playwright.dev/docs/api/class-testinfo).
* @param condition Test is marked as "should fail" when the condition is `true`.
* @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as
* "should fail" when the return value is `true`.
* @param condition Test is marked as "skipped" when the condition is `true`.
* @param callback A function that returns whether to mark as "skipped", based on test fixtures. Test or tests are marked as "skipped"
* when the return value is `true`.
* @param description Optional description that will be reflected in a test report.
*/
skip(condition: boolean, description?: string): void;
Expand Down Expand Up @@ -4510,7 +4510,7 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* });
* ```
*
* You can also call `test.skip()` without arguments inside the test body to always mark the test as failed. We
* You can also call `test.skip()` without arguments inside the test body to always skip the test. However, we
* recommend using `test.skip(title, body)` instead.
*
* ```js
Expand All @@ -4527,9 +4527,9 @@ export interface TestType<TestArgs extends {}, WorkerArgs extends {}> {
* description.
* @param body Test body that takes one or two arguments: an object with fixtures and optional
* [TestInfo](https://playwright.dev/docs/api/class-testinfo).
* @param condition Test is marked as "should fail" when the condition is `true`.
* @param callback A function that returns whether to mark as "should fail", based on test fixtures. Test or tests are marked as
* "should fail" when the return value is `true`.
* @param condition Test is marked as "skipped" when the condition is `true`.
* @param callback A function that returns whether to mark as "skipped", based on test fixtures. Test or tests are marked as "skipped"
* when the return value is `true`.
* @param description Optional description that will be reflected in a test report.
*/
skip(callback: ConditionBody<TestArgs & WorkerArgs>, description?: string): void;
Expand Down
19 changes: 19 additions & 0 deletions tests/library/browsercontext-storage-state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ it('should set local storage', async ({ contextFactory }) => {
await context.close();
});

it('should report good error if the url is not valid', async ({ contextFactory }) => {
const error = await contextFactory({
storageState: {
cookies: [],
origins: [
{
origin: 'foo',
localStorage: [{
name: 'name1',
value: 'value1'
}]
},
]
}
}).catch(e => e);
expect(error.message).toContain('browser.newContext: Error setting storage state:');
expect(error.message).toContain('foo');
});

it('should round-trip through the file', async ({ contextFactory }, testInfo) => {
const context = await contextFactory();
const page1 = await context.newPage();
Expand Down
Loading