feat(tracing): allow including source files in traces (#9946)
This commit is contained in:
parent
d1b43fafd3
commit
85497c5509
|
|
@ -127,7 +127,11 @@ a timeline preview.
|
||||||
|
|
||||||
Whether to capture DOM snapshot on every action.
|
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
|
## async method: Tracing.startChunk
|
||||||
|
|
||||||
|
|
|
||||||
5
packages/playwright-core/types/types.d.ts
vendored
5
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -14394,6 +14394,11 @@ export interface Tracing {
|
||||||
* Whether to capture DOM snapshot on every action.
|
* Whether to capture DOM snapshot on every action.
|
||||||
*/
|
*/
|
||||||
snapshots?: boolean;
|
snapshots?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to include source files for trace actions.
|
||||||
|
*/
|
||||||
|
sources?: boolean;
|
||||||
}): Promise<void>;
|
}): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ export const test = _baseTest.extend<TestFixtures, WorkerAndFileFixtures>({
|
||||||
context.setDefaultNavigationTimeout(navigationTimeout || actionTimeout || 0);
|
context.setDefaultNavigationTimeout(navigationTimeout || actionTimeout || 0);
|
||||||
if (captureTrace) {
|
if (captureTrace) {
|
||||||
if (!(context.tracing as any)[kTracingStarted]) {
|
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;
|
(context.tracing as any)[kTracingStarted] = true;
|
||||||
} else {
|
} else {
|
||||||
await context.tracing.startChunk();
|
await context.tracing.startChunk();
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ const test = playwrightTest.extend<{ showTraceViewer: (trace: string) => Promise
|
||||||
runAndTrace: async ({ context, showTraceViewer }, use, testInfo) => {
|
runAndTrace: async ({ context, showTraceViewer }, use, testInfo) => {
|
||||||
await use(async (body: () => Promise<void>) => {
|
await use(async (body: () => Promise<void>) => {
|
||||||
const traceFile = testInfo.outputPath('trace.zip');
|
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 body();
|
||||||
await context.tracing.stop({ path: traceFile });
|
await context.tracing.stop({ path: traceFile });
|
||||||
return showTraceViewer(traceFile);
|
return showTraceViewer(traceFile);
|
||||||
|
|
@ -124,7 +124,7 @@ let traceFile: string;
|
||||||
|
|
||||||
test.beforeAll(async function recordTrace({ browser, browserName, browserType, server }, workerInfo) {
|
test.beforeAll(async function recordTrace({ browser, browserName, browserType, server }, workerInfo) {
|
||||||
const context = await browser.newContext();
|
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();
|
const page = await context.newPage();
|
||||||
await page.goto('data:text/html,<html>Hello world</html>');
|
await page.goto('data:text/html,<html>Hello world</html>');
|
||||||
await page.setContent('<button>Click</button>');
|
await page.setContent('<button>Click</button>');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue