You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/browser/config.md
+47-3Lines changed: 47 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ A path to the HTML entry point. Can be relative to the root of the project. This
128
128
129
129
Configure options for Vite server that serves code in the browser. Does not affect [`test.api`](#api) option. By default, Vitest assigns port `63315` to avoid conflicts with the development server, allowing you to run both in parallel.
The custom provider API is highly experimental and can change between patches. If you just need to run tests in a browser, use the [`browser.instances`](#browser-instances) option instead.
@@ -307,6 +307,50 @@ The timeout in milliseconds. If connection to the browser takes longer, the test
307
307
This is the time it should take for the browser to establish the WebSocket connection with the Vitest server. In normal circumstances, this timeout should never be reached.
Copy file name to clipboardExpand all lines: docs/guide/browser/playwright.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ export default defineConfig({
18
18
19
19
Vitest opens a single page to run all tests in the same file. You can configure the `launch`, `connect` and `context` when calling `playwright` at the top level or inside instances:
20
20
21
-
```ts{7-15,22-27} [vitest.config.js]
21
+
```ts{7-14,21-26} [vitest.config.js]
22
22
import { playwright } from '@vitest/browser/providers/playwright'
Vitest Browser Mode supports generating Playwright's [trace files](https://playwright.dev/docs/trace-viewer#viewing-remote-traces). To enable tracing, you need to set the [`trace`](/guide/browser/config#browser-trace) option in the `test.browser` configuration.
4
+
5
+
::: warning
6
+
Generating trace files is only available when using the [Playwright provider](/guide/browser/playwright).
By default, Vitest will generate a trace file for each test. You can also configure it to only generate traces on test failures by setting `trace` to `'on-first-retry'`, `'on-all-retries'` or `'retain-on-failure'`. The files will be saved in `__traces__` folder next to your test files. The name of the trace includes the project name, the test name, the [`repeats` count and `retry` count](/api/#test-api-reference):
29
+
30
+
```
31
+
chromium-my-test-0-0.trace.zip
32
+
^^^^^^^^ project name
33
+
^^^^^^ test name
34
+
^ repeat count
35
+
^ retry count
36
+
```
37
+
38
+
To change the output directory, you can set the `tracesDir` option in the `test.browser.trace` configuration. This way all traces will be stored in the same directory, grouped by the test file.
// the path is relative to the root of the project
51
+
tracesDir: './playwright-traces',
52
+
},
53
+
},
54
+
},
55
+
})
56
+
```
57
+
58
+
The traces are available in reporters as [annotations](/guide/test-annotations). For example, in the HTML reporter, you can find the link to the trace file in the test details.
59
+
60
+
## Preview
61
+
62
+
To open the trace file, you can use the Playwright Trace Viewer. Run the following command in your terminal:
63
+
64
+
```bash
65
+
npx playwright show-trace "path-to-trace-file"
66
+
```
67
+
68
+
This will start the Trace Viewer and load the specified trace file.
69
+
70
+
Alternatively, you can open the Trace Viewer in your browser at https://trace.playwright.dev and upload the trace file there.
71
+
72
+
## Limitations
73
+
74
+
At the moment, Vitest cannot populate the "Sources" tab in the Trace Viewer. This means that while you can see the actions and screenshots captured during the test, you won't be able to view the source code of your tests directly within the Trace Viewer. You will need to refer back to your code editor to see the test implementation.
0 commit comments