docs: js release notes for 1.51 (#34972)

Signed-off-by: Dmitry Gozman <dgozman@gmail.com>
Co-authored-by: Simon Knott <info@simonknott.de>
This commit is contained in:
Dmitry Gozman 2025-02-28 13:22:51 +00:00 committed by GitHub
parent 6dcb7d2bf5
commit 8d8c9a55cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 88 additions and 5 deletions

View File

@ -1527,7 +1527,7 @@ Returns storage state for this browser context, contains current cookies, local
* since: v1.51
- `indexedDB` ?<boolean>
Set to `true` to include IndexedDB in the storage state snapshot.
Set to `true` to include [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) in the storage state snapshot.
If your application uses IndexedDB to store authentication tokens, like Firebase Authentication, enable this.
:::note

View File

@ -6,6 +6,87 @@ toc_max_heading_level: 2
import LiteYouTube from '@site/src/components/LiteYouTube';
## Version 1.51
### Highlights
* New option [`option: BrowserContext.storageState.indexedDB`] for [`method: BrowserContext.storageState`] allows to save and restore IndexedDB contents. Useful when your application uses [IndexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) to store authentication tokens, like Firebase Authentication.
Here is an example following the [authentication guide](./auth.md#basic-shared-account-in-all-tests):
```js title="tests/auth.setup.ts"
import { test as setup, expect } from '@playwright/test';
import path from 'path';
const authFile = path.join(__dirname, '../playwright/.auth/user.json');
setup('authenticate', async ({ page }) => {
await page.goto('/');
// ... perform authentication steps ...
// make sure to save indexedDB
await page.context().storageState({ path: authFile, indexedDB: true });
});
```
* New option [`option: Locator.filter.visible`] for [`method: Locator.filter`] allows matching only visible elements.
```js title="example.spec.ts"
test('some test', async ({ page }) => {
// Ignore invisible todo items.
const todoItems = page.getByTestId('todo-item').filter({ visible: true });
// Check there are exactly 3 visible ones.
await expect(todoItems).toHaveCount(3);
});
```
* Set `gitCommit: 'generate'` property in [`property: TestConfig.metadata`] to capture git information that will be shown in a test report.
```js title="playwright.config.ts"
import { defineConfig } from '@playwright/test';
export default defineConfig({
metadata: { gitCommit: 'generate' },
});
```
### Test runner
* A new [TestStepInfo] object is now available in test steps. You can add step attachments or skip the step under some conditions.
```js
test('some test', async ({ page, isMobile }) => {
// Note the new "step" argument:
await test.step('here is my step', async step => {
step.skip(isMobile, 'not relevant on mobile layouts');
// ...
await step.attach('my attachment', { body: 'some text' });
// ...
});
});
```
* HTML reporter now shows the contents of [`property: TestConfig.metadata`].
### Miscellaneous
* New option `contrast` for methods [`method: Page.emulateMedia`] and [`method: Browser.newContext`] allows to emulate the `prefers-contrast` media feature.
* New option [`option: APIRequest.newContext.failOnStatusCode`] makes all fetch requests made through the [APIRequestContext] throw on response codes other than 2xx and 3xx.
* Assertion [`method: PageAssertions.toHaveURL`] now supports a predicate.
### Browser Versions
* Chromium 134.0.6998.35
* Mozilla Firefox 135.0
* WebKit 18.4
This version was also tested against the following stable channels:
* Google Chrome 133
* Microsoft Edge 133
## Version 1.50
### Test runner

View File

@ -9271,8 +9271,9 @@ export interface BrowserContext {
*/
storageState(options?: {
/**
* Set to `true` to include IndexedDB in the storage state snapshot. If your application uses IndexedDB to store
* authentication tokens, like Firebase Authentication, enable this.
* Set to `true` to include [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) in the storage
* state snapshot. If your application uses IndexedDB to store authentication tokens, like Firebase Authentication,
* enable this.
*
* **NOTE** IndexedDBs with typed arrays are currently not supported.
*

View File

@ -9271,8 +9271,9 @@ export interface BrowserContext {
*/
storageState(options?: {
/**
* Set to `true` to include IndexedDB in the storage state snapshot. If your application uses IndexedDB to store
* authentication tokens, like Firebase Authentication, enable this.
* Set to `true` to include [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) in the storage
* state snapshot. If your application uses IndexedDB to store authentication tokens, like Firebase Authentication,
* enable this.
*
* **NOTE** IndexedDBs with typed arrays are currently not supported.
*