mirror of
https://github.com/podman-desktop/podman-desktop
synced 2026-04-21 17:47:22 +00:00
chore(guidelines): add example difference between waitFor and waitUntil (#14992)
* chore(guidelines): add example difference between waitFor and waitUntil Signed-off-by: Simon Rey <51708585+simonrey1@users.noreply.github.com> * chore(guidelines): specify waitFor error Signed-off-by: Simon Rey <51708585+simonrey1@users.noreply.github.com> * chore(guidelines): apply suggestions Signed-off-by: Simon Rey <51708585+simonrey1@users.noreply.github.com> --------- Signed-off-by: Simon Rey <51708585+simonrey1@users.noreply.github.com>
This commit is contained in:
parent
d24881e522
commit
f503b7248e
1 changed files with 18 additions and 0 deletions
|
|
@ -187,6 +187,24 @@ const text = getByText('text in the page');
|
|||
expect(text).toHaveStyle({ color: '#FFFFF'});
|
||||
```
|
||||
|
||||
### `waitFor` vs `waitUntil`
|
||||
|
||||
Use `waitFor` (https://vitest.dev/api/vi.html#vi-waitfor) to retry an assertion until it passes, and `waitUntil` (https://vitest.dev/api/vi.html#vi-waituntil) to wait for a function to return a truthy value.
|
||||
|
||||
→ `waitFor` → needs an exception
|
||||
|
||||
→ `waitUntil` → needs a boolean
|
||||
|
||||
**Example:**
|
||||
|
||||
```typescript
|
||||
// Use waitFor with an assertion
|
||||
await waitFor(() => expect(get(providerInfos)).not.toHaveLength(0));
|
||||
|
||||
// Use waitUntil with a boolean value
|
||||
await vi.waitUntil(() => get(imagesInfos).length > 0);
|
||||
```
|
||||
|
||||
### Mocking a sub-component
|
||||
|
||||
To test a component in isolation without testing its sub-components, you have the possibility to mock
|
||||
|
|
|
|||
Loading…
Reference in a new issue