Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions docs/src/api/class-tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,6 @@ To specify the final trace zip file name, you need to pass `path` option to
Whether to capture screenshots during tracing. Screenshots are used to build
a timeline preview.

### option: Tracing.start.coverage
* since: v1.64
* langs: js
- `coverage` <[boolean]>

Whether to collect code coverage from istanbul-instrumented application code. Build the application with an istanbul instrumentation plugin, for example [`vite-plugin-istanbul`](https://www.npmjs.com/package/vite-plugin-istanbul) or [`babel-plugin-istanbul`](https://www.npmjs.com/package/babel-plugin-istanbul), so that pages expose the `window.__coverage__` object. Playwright collects accumulated counters from all pages and frames, including right before navigations and page closes, and stores them in istanbul format inside the trace file.

### option: Tracing.start.snapshots
* since: v1.12
* langs: js
Expand Down
1 change: 0 additions & 1 deletion docs/src/test-api/class-testoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ export default defineConfig({
- `dom` ?<[boolean]> Capture DOM snapshot on every action and record network activity. Optional.
- `aria` ?<[boolean]> Capture aria snapshot of the page on every action. Optional.
- `screen` ?<[boolean]> Capture a screenshot of the page on every action. Optional.
- `coverage` ?<[boolean]> Whether to collect coverage from istanbul-instrumented application code into the trace. Defaults to false. Optional.
- `sources` ?<[boolean]> Whether to include source files for trace actions. Defaults to true. Optional.

Whether to record trace for each test. Defaults to `'off'`. The initial run of a test is the "first run"; subsequent runs caused by [retries](../test-retries.md) are "retries".
Expand Down
10 changes: 0 additions & 10 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23429,16 +23429,6 @@ export interface Tracing {
* @param options
*/
start(options?: {
/**
* Whether to collect code coverage from istanbul-instrumented application code. Build the application with an
* istanbul instrumentation plugin, for example
* [`vite-plugin-istanbul`](https://www.npmjs.com/package/vite-plugin-istanbul) or
* [`babel-plugin-istanbul`](https://www.npmjs.com/package/babel-plugin-istanbul), so that pages expose the
* `window.__coverage__` object. Playwright collects accumulated counters from all pages and frames, including right
* before navigations and page closes, and stores them in istanbul format inside the trace file.
*/
coverage?: boolean;

/**
* When enabled, the trace is written to an unarchived file that is updated in real time as actions occur, instead of
* caching changes and archiving them into a zip file at the end. This is useful for live trace viewing during test
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/src/client/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
super(parent, type, guid, initializer);
}

async start(options: { name?: string, title?: string, snapshots?: boolean | { dom?: boolean, aria?: boolean, screen?: boolean }, screenshots?: boolean, coverage?: boolean, sources?: boolean, live?: boolean } = {}) {
async start(options: { name?: string, title?: string, snapshots?: boolean | { dom?: boolean, aria?: boolean, screen?: boolean }, screenshots?: boolean, _coverage?: boolean, sources?: boolean, live?: boolean } = {}) {
await this._wrapApiCall(async () => {
this._includeSources = !!options.sources;
this._isLive = !!options.live;
Expand All @@ -53,7 +53,7 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
snapshotAria: snapshots.aria,
snapshotScreen: snapshots.screen,
screencast: options.screenshots,
coverage: options.coverage,
coverage: options._coverage,
live: options.live,
}, kNoTimeout);
const { traceName } = await this._channel.tracingStartChunk({ name: options.name, title: options.title }, kNoTimeout);
Expand Down
10 changes: 0 additions & 10 deletions packages/playwright-core/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23429,16 +23429,6 @@ export interface Tracing {
* @param options
*/
start(options?: {
/**
* Whether to collect code coverage from istanbul-instrumented application code. Build the application with an
* istanbul instrumentation plugin, for example
* [`vite-plugin-istanbul`](https://www.npmjs.com/package/vite-plugin-istanbul) or
* [`babel-plugin-istanbul`](https://www.npmjs.com/package/babel-plugin-istanbul), so that pages expose the
* `window.__coverage__` object. Playwright collects accumulated counters from all pages and frames, including right
* before navigations and page closes, and stores them in istanbul format inside the trace file.
*/
coverage?: boolean;

/**
* When enabled, the trace is written to an unarchived file that is updated in real time as actions occur, instead of
* caching changes and archiving them into a zip file at the end. This is useful for live trace viewing during test
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/worker/testTracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const version: trace.VERSION = 10;
let traceOrdinal = 0;

type TraceFixtureValue = PlaywrightWorkerOptions['trace'] | undefined;
type TraceOptions = { screenshots: boolean, snapshots: boolean | { dom?: boolean, aria?: boolean, screen?: boolean }, coverage: boolean, sources: boolean, attachments: boolean, live: boolean, mode: TraceMode };
type TraceOptions = { screenshots: boolean, snapshots: boolean | { dom?: boolean, aria?: boolean, screen?: boolean }, _coverage: boolean, sources: boolean, attachments: boolean, live: boolean, mode: TraceMode };

export class TestTracing {
private _testInfo: TestInfoImpl;
Expand Down Expand Up @@ -93,7 +93,7 @@ export class TestTracing {
}

async startIfNeeded(value: TraceFixtureValue) {
const defaultTraceOptions: TraceOptions = { screenshots: true, snapshots: true, coverage: false, sources: true, attachments: true, live: false, mode: 'off' };
const defaultTraceOptions: TraceOptions = { screenshots: true, snapshots: true, _coverage: false, sources: true, attachments: true, live: false, mode: 'off' };

if (!value) {
this._options = defaultTraceOptions;
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
* ```
*
*/
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html'|'blob'|'perfetto'|'coverage', string> | ReporterDescription[];
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html'|'blob'|'perfetto', string> | ReporterDescription[];
/**
* Global options for all tests, for example
* [testOptions.browserName](https://playwright.dev/docs/api/class-testoptions#test-options-browser-name). Learn more
Expand Down Expand Up @@ -7260,7 +7260,7 @@ export interface PlaywrightWorkerOptions {
*
* Learn more about [recording trace](https://playwright.dev/docs/test-use-options#recording-options).
*/
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean | { dom?: boolean, aria?: boolean, screen?: boolean }, screenshots?: boolean, coverage?: boolean, sources?: boolean, attachments?: boolean };
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean | { dom?: boolean, aria?: boolean, screen?: boolean }, screenshots?: boolean, sources?: boolean, attachments?: boolean };
/**
* Whether to record video for each test. Defaults to `'off'`. The initial run of a test is the "first run";
* subsequent runs caused by [retries](https://playwright.dev/docs/test-retries) are "retries".
Expand Down
2 changes: 1 addition & 1 deletion tests/config/traceViewerFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const traceViewerFixtures: Fixtures<TraceViewerFixtures, {}, BaseTestFixt
if (process.env.PWTEST_DEBUG_TRACE_VIEWER || process.env.PWTEST_COVERAGE) {
const debug = !!process.env.PWTEST_DEBUG_TRACE_VIEWER;
// Coverage of the trace viewer itself, picked up by the coverage reporter.
await page.context().tracing.start({ snapshots: debug, screenshots: debug, coverage: !!process.env.PWTEST_COVERAGE });
await page.context().tracing.start({ snapshots: debug, screenshots: debug, _coverage: !!process.env.PWTEST_COVERAGE } as any);
tracedPages.push(page);
}
const url = cp.output.match(/Listening on (http:\/\/[^\s]+)/)![1];
Expand Down
24 changes: 12 additions & 12 deletions tests/library/coverage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const coverageScript = (file: string, s0: number) => `<script>window.__coverage_

it('should collect istanbul coverage into the trace', async ({ browser }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);

const page = await context.newPage();
await page.setContent(coverageScript('a.js', 3));
Expand All @@ -56,7 +56,7 @@ it('should collect istanbul coverage into the trace', async ({ browser }, testIn

it('should collect coverage per trace chunk', async ({ browser }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();

await page.setContent(coverageScript('a.js', 5));
Expand All @@ -82,7 +82,7 @@ it('should collect coverage per trace chunk', async ({ browser }, testInfo) => {

it('should report maps once and counters incrementally', async ({ browser, server }) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);

Expand Down Expand Up @@ -110,7 +110,7 @@ it('should report maps once and counters incrementally', async ({ browser, serve

it('should accumulate counters across pulls and keep never hit files', async ({ browser }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();
await page.setContent(coverageScript('a.js', 0));
await page.evaluate(() => (window as any).__coverage__['a.js'].s['0'] += 4);
Expand All @@ -136,7 +136,7 @@ async function openPopup(page: any, server: any, file: string, s0: number) {

it('should collect coverage of a page closed by in-page script', async ({ browser, server }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);

Expand All @@ -158,7 +158,7 @@ it('should collect coverage of a page closed by in-page script', async ({ browse

it('should not double count a stash picked up twice', async ({ browser, server }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);

Expand All @@ -180,7 +180,7 @@ it('should not double count a stash picked up twice', async ({ browser, server }

it('should discard stashes of other sessions', async ({ browser, server }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);
await page.evaluate(coverage => {
Expand All @@ -200,7 +200,7 @@ it('should discard stashes of other sessions', async ({ browser, server }, testI

it('should collect coverage of an origin left without a page', async ({ browser, server }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);

Expand Down Expand Up @@ -230,7 +230,7 @@ it('should collect coverage of an origin left without a page', async ({ browser,

it('should pull counters as the actions go', async ({ browser, server }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);
await page.setContent(coverageScript('a.js', 3));
Expand Down Expand Up @@ -264,7 +264,7 @@ it('should count only the hits after start', async ({ browser, server }, testInf
await page.goto(server.EMPTY_PAGE);
await page.evaluate(coverage => (window as any).__coverage__ = JSON.parse(coverage), JSON.stringify(fileCoverage('a.js', 3)));

await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
await page.evaluate(() => (window as any).__coverage__['a.js'].s['0'] += 2);
const traceFile = testInfo.outputPath('trace.zip');
await context.tracing.stop({ path: traceFile });
Expand All @@ -277,7 +277,7 @@ it('should count only the hits after start', async ({ browser, server }, testInf

it('should stop collecting when tracing stops', async ({ browser, server }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);
await page.evaluate(coverage => (window as any).__coverage__ = JSON.parse(coverage), JSON.stringify(fileCoverage('a.js', 1)));
Expand All @@ -294,7 +294,7 @@ it('should stop collecting when tracing stops', async ({ browser, server }, test

it('should surface a failure to stash the coverage', async ({ browser, server }, testInfo) => {
const context = await browser.newContext();
await context.tracing.start({ coverage: true });
await context.tracing.start({ _coverage: true } as any);
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);
await page.evaluate(coverage => {
Expand Down
6 changes: 3 additions & 3 deletions tests/playwright-test/coverage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('should collect istanbul coverage into the trace', async ({ runInlineTest }
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
use: { trace: { mode: 'on', coverage: true } },
use: { trace: { mode: 'on', _coverage: true } },
};
`,
'a.test.ts': `
Expand Down Expand Up @@ -86,7 +86,7 @@ test('should aggregate coverage with the coverage reporter', async ({ runInlineT
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
use: { trace: { mode: 'on', coverage: true } },
use: { trace: { mode: 'on', _coverage: true } },
reporter: [['dot'], ['coverage', { outputDir: 'coverage-report' }]],
};
`,
Expand Down Expand Up @@ -133,7 +133,7 @@ test('should warn when no coverage was collected', async ({ runInlineTest }) =>
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
use: { trace: { mode: 'on', coverage: true } },
use: { trace: { mode: 'on', _coverage: true } },
reporter: [['dot'], ['coverage', { outputDir: 'coverage-report' }]],
};
`,
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright-test/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default defineConfig({
timeout: 30000,
use: {
// Coverage of the html reporter and trace viewer pages, built with PWTEST_COVERAGE=1.
trace: process.env.PWTEST_COVERAGE ? { mode: 'on', snapshots: false, screenshots: false, coverage: true } : 'off',
trace: process.env.PWTEST_COVERAGE ? { mode: 'on', snapshots: false, screenshots: false, _coverage: true } as any : 'off',
},
forbidOnly: !!process.env.CI,
workers: undefined,
Expand Down
4 changes: 2 additions & 2 deletions utils/generate_types/overrides-test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type LiteralUnion<T extends U, U = string> = T | (U & { zz_IGNORE_ME?: never });

interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
projects?: Project<TestArgs, WorkerArgs>[];
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html'|'blob'|'perfetto'|'coverage', string> | ReporterDescription[];
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html'|'blob'|'perfetto', string> | ReporterDescription[];
use?: UseOptions<TestArgs, WorkerArgs>;
webServer?: TestConfigWebServer | TestConfigWebServer[];
}
Expand Down Expand Up @@ -272,7 +272,7 @@ export interface PlaywrightWorkerOptions {
connectOptions: ConnectOptions | undefined;
reuseContext: boolean;
screenshot: ScreenshotMode | { mode: ScreenshotMode } & Pick<PageScreenshotOptions, 'fullPage' | 'omitBackground'>;
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean | { dom?: boolean, aria?: boolean, screen?: boolean }, screenshots?: boolean, coverage?: boolean, sources?: boolean, attachments?: boolean };
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean | { dom?: boolean, aria?: boolean, screen?: boolean }, screenshots?: boolean, sources?: boolean, attachments?: boolean };
video: VideoMode | /** deprecated */ 'retry-with-video' | { mode: VideoMode, size?: ViewportSize, fps?: number, show?: { actions?: { duration?: number, position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right', /** @deprecated Use `style.title` instead. */ fontSize?: number, cursor?: 'none' | 'pointer', style?: { point?: string, highlight?: string, title?: string } }, test?: { level?: 'file' | 'title' | 'step', position?: 'top-left' | 'top' | 'top-right' | 'bottom-left' | 'bottom' | 'bottom-right', fontSize?: number } } };
}

Expand Down
Loading