Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(api): make Tracing.group return Disposable (#39729)
Pavel Feldman7a4bfa1ae6af
diff --git a/CLAUDE.md b/CLAUDE.mdindex 9b85a3d23f..d5bdcd3a62 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -96,6 +96,8 @@ When creating or moving files, update the relevant `DEPS.list` to declare allowe## Commit Convention+Before committing, run `npm run flint` and fix errors.+Semantic commit messages: `label(scope): description`Labels: `fix`, `feat`, `chore`, `docs`, `test`, `devops`diff --git a/docs/src/api/class-tracing.md b/docs/src/api/class-tracing.mdindex 704409a170..9c4b5221d0 100644--- a/docs/src/api/class-tracing.md+++ b/docs/src/api/class-tracing.md@@ -305,6 +305,7 @@ To specify the final trace zip file name, you need to pass `path` option to## async method: Tracing.group* since: v1.49+- returns: <[Disposable]>:::cautionUse `test.step` instead when available.diff --git a/packages/playwright-client/types/types.d.ts b/packages/playwright-client/types/types.d.tsindex 572435010d..3f8e9d677c 100644--- a/packages/playwright-client/types/types.d.ts+++ b/packages/playwright-client/types/types.d.ts@@ -21957,7 +21957,7 @@ export interface Tracing {column?: number;};- }): Promise<void>;+ }): Promise<Disposable>;/*** Closes the last group created bydiff --git a/packages/playwright-core/src/client/tracing.ts b/packages/playwright-core/src/client/tracing.tsindex cd5e06ff5d..5fed143e0a 100644--- a/packages/playwright-core/src/client/tracing.ts+++ b/packages/playwright-core/src/client/tracing.ts@@ -16,6 +16,7 @@import { Artifact } from './artifact';import { ChannelOwner } from './channelOwner';+import { DisposableStub } from './disposable';import type * as api from '../../types/types';import type * as channels from '@protocol/channels';@@ -62,6 +63,7 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements apif (options.location)this._additionalSources.add(options.location.file);await this._channel.tracingGroup({ name, location: options.location });+ return new DisposableStub(() => this.groupEnd());}async groupEnd() {diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.tsindex 572435010d..3f8e9d677c 100644--- a/packages/playwright-core/types/types.d.ts+++ b/packages/playwright-core/types/types.d.ts@@ -21957,7 +21957,7 @@ export interface Tracing {column?: number;};- }): Promise<void>;+ }): Promise<Disposable>;/*** Closes the last group created bydiff --git a/tests/library/screencast.spec.ts b/tests/library/screencast.spec.tsindex 69bdfbe150..7ab98d300b 100644--- a/tests/library/screencast.spec.ts+++ b/tests/library/screencast.spec.ts@@ -97,9 +97,9 @@ test('screencast.start dispose stops screencast', async ({ browser, server, tracconst page = await context.newPage();const frames: { data: Buffer }[] = [];- page.screencast().on('screencastframe', frame => frames.push(frame));+ page.screencast.on('screencastframe', frame => frames.push(frame));- const disposable = await page.screencast().start({ maxSize: { width: 500, height: 400 } });+ const disposable = await page.screencast.start({ maxSize: { width: 500, height: 400 } });await page.goto(server.EMPTY_PAGE);await page.evaluate(() => document.body.style.backgroundColor = 'red');await rafraf(page, 100);