Skip to content

Commit 36687bc

Browse files
authored
Update async-suspense.md
Without flushPromises() after mounting an async component, the wrapper will be empty.
1 parent 71f1165 commit 36687bc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/guide/advanced/async-suspense.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,14 @@ const Async = defineComponent({
129129
must be tested as follow:
130130

131131
```js
132-
test('Async component', () => {
132+
test('Async component', async () => {
133133
const TestComponent = defineComponent({
134134
components: { Async },
135135
template: '<Suspense><Async/></Suspense>'
136136
})
137137

138138
const wrapper = mount(TestComponent)
139+
await flushPromises();
139140
// ...
140141
})
141142
```
@@ -146,4 +147,4 @@ test('Async component', () => {
146147
- Use `await nextTick()` to ensure the DOM has updated before the test continues.
147148
- Functions that might update the DOM (like `trigger` and `setValue`) return `nextTick`, so you need to `await` them.
148149
- Use `flushPromises` from Vue Test Utils to resolve any unresolved promises from non-Vue dependencies (such as API requests).
149-
- Use `Suspense` to test components with an asynchronous `setup`.
150+
- Use `Suspense` to test components with an asynchronous `setup` in an asynchronous test function.

0 commit comments

Comments
 (0)