diff --git a/docs/src/test-api/class-test.md b/docs/src/test-api/class-test.md index d976058aef18d..ab0efba7fb423 100644 --- a/docs/src/test-api/class-test.md +++ b/docs/src/test-api/class-test.md @@ -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'; @@ -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 diff --git a/packages/playwright-core/src/server/browserContext.ts b/packages/playwright-core/src/server/browserContext.ts index 00ecf1792de8d..48668e6314a43 100644 --- a/packages/playwright-core/src/server/browserContext.ts +++ b/packages/playwright-core/src/server/browserContext.ts @@ -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'; @@ -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; } diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts index 1a94bc605c8ac..45916cef6370a 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -4186,7 +4186,7 @@ export interface TestType { * }); * ``` * - * 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 @@ -4203,9 +4203,9 @@ export interface TestType { * 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): void; @@ -4267,7 +4267,7 @@ export interface TestType { * }); * ``` * - * 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 @@ -4284,9 +4284,9 @@ export interface TestType { * 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): void; @@ -4348,7 +4348,7 @@ export interface TestType { * }); * ``` * - * 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 @@ -4365,9 +4365,9 @@ export interface TestType { * 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; @@ -4429,7 +4429,7 @@ export interface TestType { * }); * ``` * - * 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 @@ -4446,9 +4446,9 @@ export interface TestType { * 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; @@ -4510,7 +4510,7 @@ export interface TestType { * }); * ``` * - * 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 @@ -4527,9 +4527,9 @@ export interface TestType { * 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, description?: string): void; diff --git a/tests/library/browsercontext-storage-state.spec.ts b/tests/library/browsercontext-storage-state.spec.ts index 972453e1b2eb9..4f4fca6cee201 100644 --- a/tests/library/browsercontext-storage-state.spec.ts +++ b/tests/library/browsercontext-storage-state.spec.ts @@ -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();