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
This is a Vite's [`DevEnvironment`](https://vite.dev/guide/api-environment) that transforms all files inside of the test module.
Ifmetadatawasattachedduringcollection (outsideofthe`test`function), then it will be available in [`onTestModuleCollected`](./reporters#ontestmodulecollected) hook in the custom reporter.
The`configurePrettyDOM`function allows you to configure default options for the `prettyDOM` and `debug` functions. This is useful for customizing how HTML is formatted in test failure messages.
238
+
239
+
```ts
240
+
import { utils } from'vitest/browser'
241
+
242
+
utils.configurePrettyDOM({
243
+
maxDepth: 3,
244
+
filterNode: 'script, style, [data-test-hide]'
245
+
})
246
+
```
247
+
248
+
#### Options
249
+
250
+
- **`maxDepth`** - Maximum depth to print nested elements (default: `Infinity`)
251
+
- **`maxLength`** - Maximum length of the output string (default: `7000`)
252
+
- **`filterNode`** - A CSS selector string or function to filter out nodes from the output. When a string is provided, elements matching the selector will be excluded. When a function is provided, it should return `false` to exclude a node.
- And other options from [`pretty-format`](https://www.npmjs.com/package/@vitest/pretty-format)
255
+
256
+
#### Filtering with CSS Selectors <Version>4.1.0</Version> {#filtering-with-css-selectors}
257
+
258
+
The `filterNode` option allows you to hide irrelevant markup (like scripts, styles, or hidden elements) from test failure messages, making it easier to identify the actual cause of failures.
This feature is inspired by Testing Library's [`defaultIgnore`](https://testing-library.com/docs/dom-testing-library/api-configuration/#defaultignore) configuration.
When enabled, Vitest uses Playwright's [persistent context](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context) instead of a regular browser context. This allows browser state (cookies, localStorage, DevTools settings, etc.) to persist between test runs.
114
+
115
+
::: warning
116
+
This option is ignored when running tests in parallel (e.g. when headless with [`fileParallelism`](/config/fileparallelism) enalbed) since persistent context cannot be shared across parallel sessions.
117
+
:::
118
+
119
+
- When set to `true`, the user data is stored in `./node_modules/.cache/vitest-playwright-user-data`
120
+
- When set to a string, the value is used as the path to the user data directory
0 commit comments