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
@@ -154,6 +156,8 @@ This method is a shortcut for `console.log(prettyDOM(baseElement))`. It will pri
154
156
function rerender(ui:React.ReactNode):Promise<void>
155
157
```
156
158
159
+
Also records a `react.rerender` trace mark in the [Trace View](/guide/browser/trace-view).
160
+
157
161
It is better if you test the component that's doing the prop updating to ensure that the props are being updated correctly to avoid relying on implementation details in your tests. That said, if you'd prefer to update the props of a rendered component in your test, this function can be used to update props of the rendered component.
Also records a `react.unmount` trace mark in the [Trace View](/guide/browser/trace-view).
179
+
174
180
This will cause the rendered component to be unmounted. This is useful for testing what happens when your component is removed from the page (liketestingthatyoudon't leave event handlers hanging around causing memory leaks).
The`render`function supports either options that you can pass down to [`mount`](https://svelte.dev/docs/svelte/imperative-component-api#mount) or props directly:
48
59
49
60
```ts
50
-
const screen = render(Component, {
61
+
const screen = await render(Component, {
51
62
props: { // [!code --]
52
63
initialCount: 1, // [!code --]
53
64
}, // [!code --]
@@ -68,7 +79,7 @@ For example, if you are unit testing a `tbody` element, it cannot be a child of
68
79
```ts
69
80
const table = document.createElement('table')
70
81
71
-
const screen = render(TableBody, {
82
+
const screen = await render(TableBody, {
72
83
props,
73
84
// ⚠️ appending the element to `body` manually before rendering
74
85
target: document.body.appendChild(table),
@@ -86,7 +97,7 @@ If the `target` is specified, then this defaults to that, otherwise this default
86
97
Inadditiontodocumentedreturnvalue, the`render`functionalsoreturnsallavailable [locators](/api/browser/locators) relative to the [`baseElement`](#baseelement), including [custom ones](/api/browser/locators#custom-locators).
@@ -118,7 +129,7 @@ The [locator](/api/browser/locators) of your `container`. It is useful to use qu
118
129
```ts
119
130
import { render } from 'vitest-browser-svelte'
120
131
121
-
const { locator } = render(NumberDisplay, {
132
+
const { locator } = await render(NumberDisplay, {
122
133
number: 2,
123
134
})
124
135
@@ -139,15 +150,15 @@ This method is a shortcut for `console.log(prettyDOM(baseElement))`. It will pri
139
150
#### rerender
140
151
141
152
```ts
142
-
function rerender(props: Partial<ComponentProps<T>>): void
153
+
function rerender(props: Partial<ComponentProps<T>>): Promise<void>
143
154
```
144
155
145
-
Updatesthecomponent's props and waits for Svelte to apply the changes. Use this to test how your component responds to prop changes.
156
+
Updatesthecomponent's props and waits for Svelte to apply the changes. Use this to test how your component responds to prop changes. Also records a `svelte.rerender` trace mark in the [Trace View](/guide/browser/trace-view).
The`render`function supports all [`mount` options](https://test-utils.vuejs.org/api/#mount) from `@vue/test-utils` (except `attachTo` - use `container` instead). In addition to them, there are also `container` and `baseElement`.
@@ -56,7 +67,7 @@ For example, if you are unit testing a `tbody` element, it cannot be a child of
56
67
```js
57
68
const table = document.createElement('table')
58
69
59
-
const { container } = render(TableBody, {
70
+
const { container } = await render(TableBody, {
60
71
props,
61
72
// ⚠️ appending the element to `body` manually before rendering
62
73
container: document.body.appendChild(table),
@@ -72,7 +83,7 @@ If the `container` is specified, then this defaults to that, otherwise this defa
72
83
Inadditiontodocumentedreturnvalue, the`render`functionalsoreturnsallavailable [locators](/api/browser/locators) relative to the [`baseElement`](#baseelement), including [custom ones](/api/browser/locators#custom-locators).
Itisbetterifyoutestthecomponentthat's doing the prop updating to ensure that the props are being updated correctly to avoid relying on implementation details in your tests. That said, if you'dprefertoupdatethepropsofarenderedcomponentinyourtest, thisfunction can be used to update props of the rendered component.
Copy file name to clipboardExpand all lines: docs/guide/browser/visual-regression-testing.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -606,7 +606,6 @@ screenshots should use the service.
606
606
607
607
The cleanest approach is using [Test Projects](/guide/projects):
608
608
609
-
610
609
```ts [vitest.config.ts]
611
610
import { env } from 'node:process'
612
611
import { defineConfig } from 'vitest/config'
@@ -663,7 +662,6 @@ export default defineConfig({
663
662
})
664
663
```
665
664
666
-
667
665
Follow the [official guide to create a Playwright Workspace](https://learn.microsoft.com/en-us/azure/app-testing/playwright-workspaces/quickstart-run-end-to-end-tests?tabs=playwrightcli&pivots=playwright-test-runner#create-a-workspace).
668
666
669
667
Once your workspace is created, configure Vitest to use it:
Copy file name to clipboardExpand all lines: docs/guide/reporters.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,6 +98,10 @@ This example will write separate JSON and XML reports as well as printing a verb
98
98
99
99
By default (i.e. if no reporter is specified), Vitest will display summary of running tests and their status at the bottom. Once a suite passes, its status will be reported on top of the summary.
100
100
101
+
::: tip
102
+
When Vitest detects it is running inside an AI coding agent, the [`agent`](#agent-reporter) reporter is used instead to reduce output and minimize token usage. You can override this by explicitly configuring the [`reporters`](/config/reporters) option.
103
+
:::
104
+
101
105
You can disable the summary by configuring the reporter:
Outputs a minimal report optimized for AI coding assistants and LLM-based workflows. Only failed tests and their error messages are displayed. Console logs from passing tests and the summary section are suppressed to reduce token usage.
647
+
648
+
This reporter is automatically enabled when no `reporters` option is configured and Vitest detects it is running inside an AI coding agent. If you configure custom reporters, you can explicitly add `agent`:
649
+
650
+
:::code-group
651
+
```bash [CLI]
652
+
npx vitest --reporter=agent
653
+
```
654
+
655
+
```ts [vitest.config.ts]
656
+
exportdefaultdefineConfig({
657
+
test: {
658
+
reporters: ['agent']
659
+
},
660
+
})
661
+
```
662
+
:::
663
+
640
664
### Blob Reporter
641
665
642
666
Stores test results on the machine so they can be later merged using [`--merge-reports`](/guide/cli#merge-reports) command.
0 commit comments