Skip to content

Commit

Permalink
chore: hide tracing calls from traces (#27096)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Sep 15, 2023
1 parent a34030b commit 527d260
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
8 changes: 5 additions & 3 deletions packages/playwright-core/src/client/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/library/browsercontext-reuse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
2 changes: 0 additions & 2 deletions tests/library/inspector/pause.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)"]');
Expand Down
13 changes: 0 additions & 13 deletions tests/playwright-test/playwright.trace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
]);
Expand All @@ -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',
Expand All @@ -134,7 +128,6 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
' fixture: page',
' fixture: context',
' fixture: request',
' tracing.stopChunk',
' apiRequestContext.dispose',
]);
});
Expand Down Expand Up @@ -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',
Expand All @@ -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',
]);

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 527d260

Please sign in to comment.