Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(coverage): hide public coverage tracing options before release (#43030)

Yury Semikhatsky46c9a5331a27
diff --git a/docs/src/api/class-tracing.md b/docs/src/api/class-tracing.md
index c00debbb4a..54cfddf8fe 100644
--- a/docs/src/api/class-tracing.md
+++ b/docs/src/api/class-tracing.md
@@ -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
diff --git a/docs/src/test-api/class-testoptions.md b/docs/src/test-api/class-testoptions.md
index 879fa62417..f4c3c1e936 100644
--- a/docs/src/test-api/class-testoptions.md
+++ b/docs/src/test-api/class-testoptions.md
@@ -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".
diff --git a/packages/playwright-client/types/types.d.ts b/packages/playwright-client/types/types.d.ts
index b86402670e..8ba8d80428 100644
--- a/packages/playwright-client/types/types.d.ts
+++ b/packages/playwright-client/types/types.d.ts
@@ -23489,16 +23489,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
diff --git a/packages/playwright-core/src/client/tracing.ts b/packages/playwright-core/src/client/tracing.ts
index b191bc99db..705a6c3369 100644
--- a/packages/playwright-core/src/client/tracing.ts
+++ b/packages/playwright-core/src/client/tracing.ts
@@ -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;
@@ -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);
diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts
index b86402670e..8ba8d80428 100644
--- a/packages/playwright-core/types/types.d.ts
+++ b/packages/playwright-core/types/types.d.ts
@@ -23489,16 +23489,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
diff --git a/packages/playwright/src/worker/testTracing.ts b/packages/playwright/src/worker/testTracing.ts
index 8b8637544e..700be901a7 100644
--- a/packages/playwright/src/worker/testTracing.ts
+++ b/packages/playwright/src/worker/testTracing.ts
@@ -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;
@@ -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;
diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts
index 30ac1fbc30..033029cc5a 100644
--- a/packages/playwright/types/test.d.ts
+++ b/packages/playwright/types/test.d.ts
@@ -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
@@ -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".
diff --git a/tests/config/traceViewerFixtures.ts b/tests/config/traceViewerFixtures.ts
index 949dc08549..da6b48b3b8 100644
--- a/tests/config/traceViewerFixtures.ts
+++ b/tests/config/traceViewerFixtures.ts
@@ -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];
diff --git a/tests/library/coverage.spec.ts b/tests/library/coverage.spec.ts
index 65b4be90d8..540aa3927f 100644
--- a/tests/library/coverage.spec.ts
+++ b/tests/library/coverage.spec.ts
@@ -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));
@@ -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));
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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 => {
@@ -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);
@@ -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));
@@ -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 });
@@ -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)));
@@ -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 => {
diff --git a/tests/playwright-test/coverage.spec.ts b/tests/playwright-test/coverage.spec.ts
index f00a17b582..574dd81c2c 100644
--- a/tests/playwright-test/coverage.spec.ts
+++ b/tests/playwright-test/coverage.spec.ts
@@ -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': `
@@ -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' }]],
};
`,
@@ -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' }]],
};
`,
diff --git a/tests/playwright-test/playwright.config.ts b/tests/playwright-test/playwright.config.ts
index 3ad2e95597..1a11d9c490 100644
--- a/tests/playwright-test/playwright.config.ts
+++ b/tests/playwright-test/playwright.config.ts
@@ -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,
diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts
index bb5105866a..88cb51be18 100644
--- a/utils/generate_types/overrides-test.d.ts
+++ b/utils/generate_types/overrides-test.d.ts
@@ -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[];
}
@@ -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 } } };
}