Skip to content

Tracing

The device.tracing API provides programmatic control over trace recording.

Start tracing. All subsequent device actions will be recorded.

await device.tracing.start();
await device.tracing.start({ screenshots: true, snapshots: true });

Options:

OptionTypeDefaultDescription
screenshotsbooleantrueCapture before/after screenshots
snapshotsbooleantrueCapture view hierarchy XML
sourcesbooleantrueInclude test source files
networkbooleantrueCapture HTTP/HTTPS traffic via proxy
titlestringCustom title for the trace

Stop tracing and optionally write the trace archive.

// Stop and save
await device.tracing.stop({ path: 'traces/my-test.zip' });
// Stop and discard
await device.tracing.stop();

Returns the path to the created zip file, or undefined if no path was specified.

device.tracing.group(name) / device.tracing.groupEnd()

Section titled “device.tracing.group(name) / device.tracing.groupEnd()”

Group actions in the trace viewer for better organization.

device.tracing.group('Login flow');
await device.getByText('Username', { exact: true }).tap();
await device.getByText('Username', { exact: true }).type('admin');
await device.getByRole('button', { name: 'Sign In' }).tap();
device.tracing.groupEnd();

device.tracing.startChunk(options?) / device.tracing.stopChunk(options?)

Section titled “device.tracing.startChunk(options?) / device.tracing.stopChunk(options?)”

Start a new trace chunk. Useful for splitting long test runs into multiple trace files.

await device.tracing.startChunk();
// ... actions ...
await device.tracing.stopChunk({ path: 'traces/chunk-1.zip' });
await device.tracing.startChunk();
// ... more actions ...
await device.tracing.stopChunk({ path: 'traces/chunk-2.zip' });