···3939): Promise<RenderResult>
4040```
41414242+The `render` function records a `react.render` trace mark, visible in the [Trace View](/guide/browser/trace-view).
4343+4244:::warning
4345Note that `render` is asynchronous, unlike in other packages. This is to support [`Suspense`](https://react.dev/reference/react/Suspense) correctly.
4446···154156function rerender(ui: React.ReactNode): Promise<void>
155157```
156158159159+Also records a `react.rerender` trace mark in the [Trace View](/guide/browser/trace-view).
160160+157161It 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.
158162159163```jsx
···170174```ts
171175function unmount(): Promise<void>
172176```
177177+178178+Also records a `react.unmount` trace mark in the [Trace View](/guide/browser/trace-view).
173179174180This will cause the rendered component to be unmounted. This is useful for testing what happens when your component is removed from the page (like testing that you don't leave event handlers hanging around causing memory leaks).
175181
+32-17
docs/api/browser/svelte.md
···1212import Component from './Component.svelte'
13131414test('counter button increments the count', async () => {
1515- const screen = render(Component, {
1515+ const screen = await render(Component, {
1616 initialCount: 1,
1717 })
1818···3939 Component: ComponentImport<C>,
4040 options?: ComponentOptions<C>,
4141 renderOptions?: SetupOptions
4242-): RenderResult<C>
4242+): RenderResult<C> & PromiseLike<RenderResult<C>>
4343```
4444+4545+The `render` function records a `svelte.render` trace mark, visible in the [Trace View](/guide/browser/trace-view).
4646+4747+::: warning
4848+Synchronous usage of `render` is deprecated and will be removed in the next major version. Please always `await` the result:
4949+5050+```ts
5151+const screen = render(Component) // [!code --]
5252+const screen = await render(Component) // [!code ++]
5353+```
5454+:::
44554556### Options
46574758The `render` function supports either options that you can pass down to [`mount`](https://svelte.dev/docs/svelte/imperative-component-api#mount) or props directly:
48594960```ts
5050-const screen = render(Component, {
6161+const screen = await render(Component, {
5162 props: { // [!code --]
5263 initialCount: 1, // [!code --]
5364 }, // [!code --]
···6879```ts
6980const table = document.createElement('table')
70817171-const screen = render(TableBody, {
8282+const screen = await render(TableBody, {
7283 props,
7384 // ⚠️ appending the element to `body` manually before rendering
7485 target: document.body.appendChild(table),
···8697In addition to documented return value, the `render` function also returns all available [locators](/api/browser/locators) relative to the [`baseElement`](#baseelement), including [custom ones](/api/browser/locators#custom-locators).
87988899```ts
8989-const screen = render(TableBody, props)
100100+const screen = await render(TableBody, props)
9010191102await screen.getByRole('link', { name: 'Expand' }).click()
92103```
···104115The mounted Svelte component instance. You can use this to access component methods and properties if needed.
105116106117```ts
107107-const { component } = render(Counter, {
118118+const { component } = await render(Counter, {
108119 initialCount: 0,
109120})
110121···118129```ts
119130import { render } from 'vitest-browser-svelte'
120131121121-const { locator } = render(NumberDisplay, {
132132+const { locator } = await render(NumberDisplay, {
122133 number: 2,
123134})
124135···139150#### rerender
140151141152```ts
142142-function rerender(props: Partial<ComponentProps<T>>): void
153153+function rerender(props: Partial<ComponentProps<T>>): Promise<void>
143154```
144155145145-Updates the component's props and waits for Svelte to apply the changes. Use this to test how your component responds to prop changes.
156156+Updates the component'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).
146157147158```ts
148159import { render } from 'vitest-browser-svelte'
149160150150-const { rerender } = render(NumberDisplay, {
161161+const { rerender } = await render(NumberDisplay, {
151162 number: 1,
152163})
153164···158169#### unmount
159170160171```ts
161161-function unmount(): void
172172+function unmount(): Promise<void>
162173```
163174164164-Unmount and destroy the Svelte component. This is useful for testing what happens when your component is removed from the page (like testing that you don't leave event handlers hanging around causing memory leaks).
175175+Unmount and destroy the Svelte component. Also records a `svelte.unmount` trace mark in the [Trace View](/guide/browser/trace-view). This is useful for testing what happens when your component is removed from the page (like testing that you don't leave event handlers hanging around causing memory leaks).
176176+177177+::: warning
178178+Synchronous usage of `unmount` is deprecated and will be removed in the next major version. Please always `await` the result.
179179+:::
165180166181```ts
167182import { render } from 'vitest-browser-svelte'
168183169169-const { container, unmount } = render(Component)
170170-unmount()
184184+const { container, unmount } = await render(Component)
185185+await unmount()
171186// your component has been unmounted and now: container.innerHTML === ''
172187```
173188···193208 },
194209})
195210196196-const screen = render(Component)
211211+const screen = await render(Component)
197212await expect.element(
198213 screen.getByArticleTitle('Hello World')
199214).toBeVisible()
···211226import SubjectTest from './basic-snippet.test.svelte'
212227213228test('basic snippet', async () => {
214214- const screen = render(SubjectTest)
229229+ const screen = await render(SubjectTest)
215230216231 const heading = screen.getByRole('heading')
217232 const child = heading.getByTestId('child')
···250265import Subject from './complex-snippet.svelte'
251266252267test('renders greeting in message snippet', async () => {
253253- const screen = render(Subject, {
268268+ const screen = await render(Subject, {
254269 name: 'Alice',
255270 message: createRawSnippet(greeting => ({
256271 render: () => `<span data-testid="message">${greeting()}</span>`,
+32-11
docs/api/browser/vue.md
···1212import Component from './Component.vue'
13131414test('counter button increments the count', async () => {
1515- const screen = render(Component, {
1515+ const screen = await render(Component, {
1616 props: {
1717 initialCount: 1,
1818 }
···4040export function render(
4141 component: Component,
4242 options?: ComponentRenderOptions,
4343-): RenderResult
4343+): RenderResult & PromiseLike<RenderResult>
4444```
4545+4646+The `render` function records a `vue.render` trace mark, visible in the [Trace View](/guide/browser/trace-view).
4747+4848+::: warning
4949+Synchronous usage of `render` is deprecated and will be removed in the next major version. Please always `await` the result:
5050+5151+```ts
5252+const screen = render(Component) // [!code --]
5353+const screen = await render(Component) // [!code ++]
5454+```
5555+:::
45564657### Options
4758···5667```js
5768const table = document.createElement('table')
58695959-const { container } = render(TableBody, {
7070+const { container } = await render(TableBody, {
6071 props,
6172 // ⚠️ appending the element to `body` manually before rendering
6273 container: document.body.appendChild(table),
···7283In addition to documented return value, the `render` function also returns all available [locators](/api/browser/locators) relative to the [`baseElement`](#baseelement), including [custom ones](/api/browser/locators#custom-locators).
73847485```ts
7575-const screen = render(TableBody, { props })
8686+const screen = await render(TableBody, { props })
76877788await screen.getByRole('link', { name: 'Expand' }).click()
7889```
···102113```js
103114import { render } from 'vitest-browser-vue'
104115105105-const { locator } = render(NumberDisplay, {
116116+const { locator } = await render(NumberDisplay, {
106117 props: { number: 2 }
107118})
108119···125136#### rerender
126137127138```ts
128128-function rerender(props: Partial<Props>): void
139139+function rerender(props: Partial<Props>): void & PromiseLike<void>
129140```
130141142142+Also records a `vue.rerender` trace mark in the [Trace View](/guide/browser/trace-view).
143143+131144It 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.
145145+146146+::: warning
147147+Synchronous usage of `rerender` is deprecated and will be removed in the next major version. Please always `await` the result.
148148+:::
132149133150```js
134151import { render } from 'vitest-browser-vue'
135152136136-const { rerender } = render(NumberDisplay, { props: { number: 1 } })
153153+const { rerender } = await render(NumberDisplay, { props: { number: 1 } })
137154138155// re-render the same component with different props
139139-rerender({ number: 2 })
156156+await rerender({ number: 2 })
140157```
141158142159#### unmount
143160144161```ts
145145-function unmount(): void
162162+function unmount(): void & PromiseLike<void>
146163```
147164148148-This will cause the rendered component to be unmounted. This is useful for testing what happens when your component is removed from the page (like testing that you don't leave event handlers hanging around causing memory leaks).
165165+This will cause the rendered component to be unmounted. Also records a `vue.unmount` trace mark in the [Trace View](/guide/browser/trace-view). This is useful for testing what happens when your component is removed from the page (like testing that you don't leave event handlers hanging around causing memory leaks).
166166+167167+::: warning
168168+Synchronous usage of `unmount` is deprecated and will be removed in the next major version. Please always `await` the result.
169169+:::
149170150171#### emitted
151172···182203 },
183204})
184205185185-const screen = render(Component)
206206+const screen = await render(Component)
186207await expect.element(
187208 screen.getByArticleTitle('Hello World')
188209).toBeVisible()