mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs(tracing): clarify diff between test tracing and context.tracing
(#35852)
This commit is contained in:
parent
8e08fdb52c
commit
00429efc4a
@ -3,6 +3,12 @@
|
||||
|
||||
API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](../trace-viewer.md) after Playwright script runs.
|
||||
|
||||
:::note
|
||||
You probably want to [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead of using `context.tracing`.
|
||||
|
||||
The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions (like `expect` calls). We recommend [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace), which includes those assertions and provides a more complete trace for debugging test failures.
|
||||
:::
|
||||
|
||||
Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
|
||||
|
||||
```js
|
||||
@ -11,6 +17,7 @@ const context = await browser.newContext();
|
||||
await context.tracing.start({ screenshots: true, snapshots: true });
|
||||
const page = await context.newPage();
|
||||
await page.goto('https://playwright.dev');
|
||||
expect(page.url()).toBe('https://playwright.dev');
|
||||
await context.tracing.stop({ path: 'trace.zip' });
|
||||
```
|
||||
|
||||
@ -66,12 +73,19 @@ await context.Tracing.StopAsync(new()
|
||||
|
||||
Start tracing.
|
||||
|
||||
:::note
|
||||
You probably want to [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead of using `Tracing.start`.
|
||||
|
||||
The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions (like `expect` calls). We recommend [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace), which includes those assertions and provides a more complete trace for debugging test failures.
|
||||
:::
|
||||
|
||||
**Usage**
|
||||
|
||||
```js
|
||||
await context.tracing.start({ screenshots: true, snapshots: true });
|
||||
const page = await context.newPage();
|
||||
await page.goto('https://playwright.dev');
|
||||
expect(page.url()).toBe('https://playwright.dev');
|
||||
await context.tracing.stop({ path: 'trace.zip' });
|
||||
```
|
||||
|
||||
|
20
packages/playwright-client/types/types.d.ts
vendored
20
packages/playwright-client/types/types.d.ts
vendored
@ -21175,6 +21175,15 @@ export interface Touchscreen {
|
||||
* API for collecting and saving Playwright traces. Playwright traces can be opened in
|
||||
* [Trace Viewer](https://playwright.dev/docs/trace-viewer) after Playwright script runs.
|
||||
*
|
||||
* **NOTE** You probably want to
|
||||
* [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead
|
||||
* of using `context.tracing`.
|
||||
*
|
||||
* The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions
|
||||
* (like `expect` calls). We recommend
|
||||
* [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace),
|
||||
* which includes those assertions and provides a more complete trace for debugging test failures.
|
||||
*
|
||||
* Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
|
||||
*
|
||||
* ```js
|
||||
@ -21183,6 +21192,7 @@ export interface Touchscreen {
|
||||
* await context.tracing.start({ screenshots: true, snapshots: true });
|
||||
* const page = await context.newPage();
|
||||
* await page.goto('https://playwright.dev');
|
||||
* expect(page.url()).toBe('https://playwright.dev');
|
||||
* await context.tracing.stop({ path: 'trace.zip' });
|
||||
* ```
|
||||
*
|
||||
@ -21230,12 +21240,22 @@ export interface Tracing {
|
||||
/**
|
||||
* Start tracing.
|
||||
*
|
||||
* **NOTE** You probably want to
|
||||
* [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead
|
||||
* of using `Tracing.start`.
|
||||
*
|
||||
* The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions
|
||||
* (like `expect` calls). We recommend
|
||||
* [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace),
|
||||
* which includes those assertions and provides a more complete trace for debugging test failures.
|
||||
*
|
||||
* **Usage**
|
||||
*
|
||||
* ```js
|
||||
* await context.tracing.start({ screenshots: true, snapshots: true });
|
||||
* const page = await context.newPage();
|
||||
* await page.goto('https://playwright.dev');
|
||||
* expect(page.url()).toBe('https://playwright.dev');
|
||||
* await context.tracing.stop({ path: 'trace.zip' });
|
||||
* ```
|
||||
*
|
||||
|
20
packages/playwright-core/types/types.d.ts
vendored
20
packages/playwright-core/types/types.d.ts
vendored
@ -21175,6 +21175,15 @@ export interface Touchscreen {
|
||||
* API for collecting and saving Playwright traces. Playwright traces can be opened in
|
||||
* [Trace Viewer](https://playwright.dev/docs/trace-viewer) after Playwright script runs.
|
||||
*
|
||||
* **NOTE** You probably want to
|
||||
* [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead
|
||||
* of using `context.tracing`.
|
||||
*
|
||||
* The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions
|
||||
* (like `expect` calls). We recommend
|
||||
* [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace),
|
||||
* which includes those assertions and provides a more complete trace for debugging test failures.
|
||||
*
|
||||
* Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
|
||||
*
|
||||
* ```js
|
||||
@ -21183,6 +21192,7 @@ export interface Touchscreen {
|
||||
* await context.tracing.start({ screenshots: true, snapshots: true });
|
||||
* const page = await context.newPage();
|
||||
* await page.goto('https://playwright.dev');
|
||||
* expect(page.url()).toBe('https://playwright.dev');
|
||||
* await context.tracing.stop({ path: 'trace.zip' });
|
||||
* ```
|
||||
*
|
||||
@ -21230,12 +21240,22 @@ export interface Tracing {
|
||||
/**
|
||||
* Start tracing.
|
||||
*
|
||||
* **NOTE** You probably want to
|
||||
* [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead
|
||||
* of using `Tracing.start`.
|
||||
*
|
||||
* The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions
|
||||
* (like `expect` calls). We recommend
|
||||
* [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace),
|
||||
* which includes those assertions and provides a more complete trace for debugging test failures.
|
||||
*
|
||||
* **Usage**
|
||||
*
|
||||
* ```js
|
||||
* await context.tracing.start({ screenshots: true, snapshots: true });
|
||||
* const page = await context.newPage();
|
||||
* await page.goto('https://playwright.dev');
|
||||
* expect(page.url()).toBe('https://playwright.dev');
|
||||
* await context.tracing.stop({ path: 'trace.zip' });
|
||||
* ```
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user