Skip to content

Commit 3fa79f9

Browse files
committed
fix(api): make Tracing.group return Disposable
Tracing.group() now returns a Disposable that calls groupEnd() on dispose, enabling `await using` pattern for automatic group cleanup.
1 parent 1ed53ac commit 3fa79f9

4 files changed

Lines changed: 5 additions & 2 deletions

File tree

docs/src/api/class-tracing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ To specify the final trace zip file name, you need to pass `path` option to
305305

306306
## async method: Tracing.group
307307
* since: v1.49
308+
- returns: <[Disposable]>
308309

309310
:::caution
310311
Use `test.step` instead when available.

packages/playwright-client/types/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21957,7 +21957,7 @@ export interface Tracing {
2195721957

2195821958
column?: number;
2195921959
};
21960-
}): Promise<void>;
21960+
}): Promise<Disposable>;
2196121961

2196221962
/**
2196321963
* Closes the last group created by

packages/playwright-core/src/client/tracing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { Artifact } from './artifact';
1818
import { ChannelOwner } from './channelOwner';
19+
import { DisposableStub } from './disposable';
1920

2021
import type * as api from '../../types/types';
2122
import type * as channels from '@protocol/channels';
@@ -62,6 +63,7 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
6263
if (options.location)
6364
this._additionalSources.add(options.location.file);
6465
await this._channel.tracingGroup({ name, location: options.location });
66+
return new DisposableStub(() => this.groupEnd());
6567
}
6668

6769
async groupEnd() {

packages/playwright-core/types/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21957,7 +21957,7 @@ export interface Tracing {
2195721957

2195821958
column?: number;
2195921959
};
21960-
}): Promise<void>;
21960+
}): Promise<Disposable>;
2196121961

2196221962
/**
2196321963
* Closes the last group created by

0 commit comments

Comments
 (0)