chore: hide tracing calls from traces (#27096)

This commit is contained in:
Pavel Feldman 2023-09-15 12:55:49 -07:00 committed by GitHub
parent a34030be80
commit 527d260cbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 19 deletions

View File

@ -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 }); const response = await this._channel.tracingStartChunk({ name: options.name, title: options.title });
return response.traceName; return response.traceName;
}); }, true);
await this._startCollectingStacks(traceName); await this._startCollectingStacks(traceName);
} }
@ -63,14 +63,16 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
} }
async stopChunk(options: { path?: string } = {}) { 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 } = {}) { async stop(options: { path?: string } = {}) {
await this._wrapApiCall(async () => { await this._wrapApiCall(async () => {
await this._doStopChunk(options.path); await this._doStopChunk(options.path);
await this._channel.tracingStop(); await this._channel.tracingStop();
}); }, true);
} }
private async _doStopChunk(filePath: string | undefined) { private async _doStopChunk(filePath: string | undefined) {

View File

@ -249,7 +249,7 @@ test('should reset tracing', async ({ reusedContext, trace }, testInfo) => {
await page.evaluate('2 + 2'); await page.evaluate('2 + 2');
const error = await context.tracing.stopChunk({ path: testInfo.outputPath('trace.zip') }).catch(e => e); 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 }) => { test('should continue issuing events after closing the reused page', async ({ reusedContext, server }) => {

View File

@ -231,8 +231,6 @@ it.describe('pause', () => {
await recorderPage.waitForSelector('.source-line-paused:has-text("page.pause(); // 2")'); await recorderPage.waitForSelector('.source-line-paused:has-text("page.pause(); // 2")');
expect(await sanitizeLog(recorderPage)).toEqual([ expect(await sanitizeLog(recorderPage)).toEqual([
'page.pause- XXms', 'page.pause- XXms',
'tracing.start- XXms',
'tracing.stop- XXms',
'page.pause', 'page.pause',
]); ]);
await recorderPage.click('[title="Resume (F8)"]'); await recorderPage.click('[title="Resume (F8)"]');

View File

@ -91,12 +91,10 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
'Before Hooks', 'Before Hooks',
' fixture: request', ' fixture: request',
' apiRequest.newContext', ' apiRequest.newContext',
' tracing.start',
' fixture: browser', ' fixture: browser',
' browserType.launch', ' browserType.launch',
' fixture: context', ' fixture: context',
' browser.newContext', ' browser.newContext',
' tracing.start',
' fixture: page', ' fixture: page',
' browserContext.newPage', ' browserContext.newPage',
'page.goto', 'page.goto',
@ -105,14 +103,12 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
' fixture: page', ' fixture: page',
' fixture: context', ' fixture: context',
' fixture: request', ' fixture: request',
' tracing.stopChunk',
' apiRequestContext.dispose', ' apiRequestContext.dispose',
]); ]);
const trace2 = await parseTrace(testInfo.outputPath('test-results', 'a-api-pass', 'trace.zip')); const trace2 = await parseTrace(testInfo.outputPath('test-results', 'a-api-pass', 'trace.zip'));
expect(trace2.actionTree).toEqual([ expect(trace2.actionTree).toEqual([
'Before Hooks', 'Before Hooks',
'apiRequest.newContext', 'apiRequest.newContext',
'tracing.start',
'apiRequestContext.get', 'apiRequestContext.get',
'After Hooks', 'After Hooks',
]); ]);
@ -121,10 +117,8 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
'Before Hooks', 'Before Hooks',
' fixture: request', ' fixture: request',
' apiRequest.newContext', ' apiRequest.newContext',
' tracing.start',
' fixture: context', ' fixture: context',
' browser.newContext', ' browser.newContext',
' tracing.start',
' fixture: page', ' fixture: page',
' browserContext.newPage', ' browserContext.newPage',
'page.goto', 'page.goto',
@ -134,7 +128,6 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {
' fixture: page', ' fixture: page',
' fixture: context', ' fixture: context',
' fixture: request', ' fixture: request',
' tracing.stopChunk',
' apiRequestContext.dispose', ' apiRequestContext.dispose',
]); ]);
}); });
@ -327,7 +320,6 @@ test('should not override trace file in afterAll', async ({ runInlineTest, serve
' browserType.launch', ' browserType.launch',
' fixture: context', ' fixture: context',
' browser.newContext', ' browser.newContext',
' tracing.start',
' fixture: page', ' fixture: page',
' browserContext.newPage', ' browserContext.newPage',
'page.goto', 'page.goto',
@ -339,10 +331,8 @@ test('should not override trace file in afterAll', async ({ runInlineTest, serve
' afterAll hook', ' afterAll hook',
' fixture: request', ' fixture: request',
' apiRequest.newContext', ' apiRequest.newContext',
' tracing.start',
' apiRequestContext.get', ' apiRequestContext.get',
' fixture: request', ' fixture: request',
' tracing.stopChunk',
' apiRequestContext.dispose', ' apiRequestContext.dispose',
]); ]);
@ -636,7 +626,6 @@ test('should expand expect.toPass', async ({ runInlineTest }, testInfo) => {
' browserType.launch', ' browserType.launch',
' fixture: context', ' fixture: context',
' browser.newContext', ' browser.newContext',
' tracing.start',
' fixture: page', ' fixture: page',
' browserContext.newPage', ' browserContext.newPage',
'expect.toPass', 'expect.toPass',
@ -676,7 +665,6 @@ test('should show non-expect error in trace', async ({ runInlineTest }, testInfo
' browserType.launch', ' browserType.launch',
' fixture: context', ' fixture: context',
' browser.newContext', ' browser.newContext',
' tracing.start',
' fixture: page', ' fixture: page',
' browserContext.newPage', ' browserContext.newPage',
'expect.toBe', 'expect.toBe',
@ -757,7 +745,6 @@ test('should use custom expect message in trace', async ({ runInlineTest }, test
' browserType.launch', ' browserType.launch',
' fixture: context', ' fixture: context',
' browser.newContext', ' browser.newContext',
' tracing.start',
' fixture: page', ' fixture: page',
' browserContext.newPage', ' browserContext.newPage',
'expect to have text: find a hotel', 'expect to have text: find a hotel',