feat(tracing): allow including source files in traces (#9946)

This commit is contained in:
Pavel Feldman 2021-11-01 18:57:29 -08:00 committed by GitHub
parent d1b43fafd3
commit 85497c5509
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions

View File

@ -127,7 +127,11 @@ a timeline preview.
Whether to capture DOM snapshot on every action.
### option: Tracing.start.sources
* langs: js
- `sources` <[boolean]>
Whether to include source files for trace actions.
## async method: Tracing.startChunk

View File

@ -14394,6 +14394,11 @@ export interface Tracing {
* Whether to capture DOM snapshot on every action.
*/
snapshots?: boolean;
/**
* Whether to include source files for trace actions.
*/
sources?: boolean;
}): Promise<void>;
/**

View File

@ -188,7 +188,7 @@ export const test = _baseTest.extend<TestFixtures, WorkerAndFileFixtures>({
context.setDefaultNavigationTimeout(navigationTimeout || actionTimeout || 0);
if (captureTrace) {
if (!(context.tracing as any)[kTracingStarted]) {
await context.tracing.start({ screenshots: true, snapshots: true, sources: true } as any);
await context.tracing.start({ screenshots: true, snapshots: true, sources: true });
(context.tracing as any)[kTracingStarted] = true;
} else {
await context.tracing.startChunk();

View File

@ -110,7 +110,7 @@ const test = playwrightTest.extend<{ showTraceViewer: (trace: string) => Promise
runAndTrace: async ({ context, showTraceViewer }, use, testInfo) => {
await use(async (body: () => Promise<void>) => {
const traceFile = testInfo.outputPath('trace.zip');
await context.tracing.start({ snapshots: true, screenshots: true, sources: true } as any);
await context.tracing.start({ snapshots: true, screenshots: true, sources: true });
await body();
await context.tracing.stop({ path: traceFile });
return showTraceViewer(traceFile);
@ -124,7 +124,7 @@ let traceFile: string;
test.beforeAll(async function recordTrace({ browser, browserName, browserType, server }, workerInfo) {
const context = await browser.newContext();
await context.tracing.start({ name: 'test', screenshots: true, snapshots: true, sources: true } as any);
await context.tracing.start({ name: 'test', screenshots: true, snapshots: true, sources: true });
const page = await context.newPage();
await page.goto('data:text/html,<html>Hello world</html>');
await page.setContent('<button>Click</button>');