Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: hide tracing calls from traces (#27096)

Pavel Feldman527d260cbfed
diff --git a/packages/playwright-core/src/client/tracing.ts b/packages/playwright-core/src/client/tracing.ts
index 80d185c45a..c90cdfcee6 100644
--- a/packages/playwright-core/src/client/tracing.ts
+++ b/packages/playwright-core/src/client/tracing.ts
@@ -44,7 +44,7 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
});
const response = await this._channel.tracingStartChunk({ name: options.name, title: options.title });
return response.traceName;
- });
+ }, true);
await this._startCollectingStacks(traceName);
}
@@ -63,14 +63,16 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
}
async stopChunk(options: { path?: string } = {}) {
- await this._doStopChunk(options.path);
+ await this._wrapApiCall(async () => {
+ await this._doStopChunk(options.path);
+ }, true);
}
async stop(options: { path?: string } = {}) {
await this._wrapApiCall(async () => {
await this._doStopChunk(options.path);
await this._channel.tracingStop();
- });
+ }, true);
}
private async _doStopChunk(filePath: string | undefined) {
diff --git a/tests/library/browsercontext-reuse.spec.ts b/tests/library/browsercontext-reuse.spec.ts
index 475bab93c9..c25d66d588 100644
--- a/tests/library/browsercontext-reuse.spec.ts
+++ b/tests/library/browsercontext-reuse.spec.ts
@@ -249,7 +249,7 @@ test('should reset tracing', async ({ reusedContext, trace }, testInfo) => {
await page.evaluate('2 + 2');
const error = await context.tracing.stopChunk({ path: testInfo.outputPath('trace.zip') }).catch(e => e);
- expect(error.message).toContain('tracing.stopChunk: Must start tracing before stopping');
+ expect(error.message).toContain('Must start tracing before stopping');
});
test('should continue issuing events after closing the reused page', async ({ reusedContext, server }) => {
diff --git a/tests/library/inspector/pause.spec.ts b/tests/library/inspector/pause.spec.ts
index dabff31491..860ff50fae 100644
--- a/tests/library/inspector/pause.spec.ts
+++ b/tests/library/inspector/pause.spec.ts
@@ -231,8 +231,6 @@ it.describe('pause', () => {
await recorderPage.waitForSelector('.source-line-paused:has-text("page.pause(); // 2")');
expect(await sanitizeLog(recorderPage)).toEqual([
'page.pause- XXms',
- 'tracing.start- XXms',
- 'tracing.stop- XXms',
'page.pause',
]);
await recorderPage.click('[title="Resume (F8)"]');
diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.ts
index ae785fea38..c9b874aad6 100644
--- a/tests/playwright-test/playwright.trace.spec.ts
+++ b/tests/playwright-test/playwright.trace.spec.ts
@@ -91,12 +91,10 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
'Before Hooks',
' fixture: request',
' apiRequest.newContext',
- ' tracing.start',
' fixture: browser',
' browserType.launch',
' fixture: context',
' browser.newContext',
- ' tracing.start',
' fixture: page',
' browserContext.newPage',
'page.goto',
@@ -105,14 +103,12 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
' fixture: page',
' fixture: context',
' fixture: request',
- ' tracing.stopChunk',
' apiRequestContext.dispose',
]);
const trace2 = await parseTrace(testInfo.outputPath('test-results', 'a-api-pass', 'trace.zip'));
expect(trace2.actionTree).toEqual([
'Before Hooks',
'apiRequest.newContext',
- 'tracing.start',
'apiRequestContext.get',
'After Hooks',
]);
@@ -121,10 +117,8 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
'Before Hooks',
' fixture: request',
' apiRequest.newContext',
- ' tracing.start',
' fixture: context',
' browser.newContext',
- ' tracing.start',
' fixture: page',
' browserContext.newPage',
'page.goto',
@@ -134,7 +128,6 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
' fixture: page',
' fixture: context',
' fixture: request',
- ' tracing.stopChunk',
' apiRequestContext.dispose',
]);
});
@@ -327,7 +320,6 @@ test('should not override trace file in afterAll', async ({ runInlineTest, serve
' browserType.launch',
' fixture: context',
' browser.newContext',
- ' tracing.start',
' fixture: page',
' browserContext.newPage',
'page.goto',
@@ -339,10 +331,8 @@ test('should not override trace file in afterAll', async ({ runInlineTest, serve
' afterAll hook',
' fixture: request',
' apiRequest.newContext',
- ' tracing.start',
' apiRequestContext.get',
' fixture: request',
- ' tracing.stopChunk',
' apiRequestContext.dispose',
]);
@@ -636,7 +626,6 @@ test('should expand expect.toPass', async ({ runInlineTest }, testInfo) => {
' browserType.launch',
' fixture: context',
' browser.newContext',
- ' tracing.start',
' fixture: page',
' browserContext.newPage',
'expect.toPass',
@@ -676,7 +665,6 @@ test('should show non-expect error in trace', async ({ runInlineTest }, testInfo
' browserType.launch',
' fixture: context',
' browser.newContext',
- ' tracing.start',
' fixture: page',
' browserContext.newPage',
'expect.toBe',
@@ -757,7 +745,6 @@ test('should use custom expect message in trace', async ({ runInlineTest }, test
' browserType.launch',
' fixture: context',
' browser.newContext',
- ' tracing.start',
' fixture: page',
' browserContext.newPage',
'expect to have text: find a hotel',