Skip to content

Commit

Permalink
Fix waitUntil usage examples (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
bearfriend authored Mar 4, 2024
1 parent 1956257 commit 243b065
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,21 +315,21 @@ it('should not wait', async() => {

#### Waiting for a Condition

In cases where there are no other reliable hooks (like events, `getUpdateComplete()` or `getLoadingComplete()`), `waitUntil(condition)` can be used to wait for a particular condition to become `true`. The condition can optionally return a Promise.
In cases where there are no other reliable hooks (like events, `getUpdateComplete()` or `getLoadingComplete()`), `waitUntil(condition, failMessage)` can be used to wait for a particular condition to become `true`. The condition can optionally return a Promise.

```javascript
import { fixture, waitUntil } from '@brightspace-ui/testing';

it('should wait for condition', async() => {
const elem = await fixture(...);
await waitUntil(() => elem.foo === 'bar');
await waitUntil(() => elem.foo === 'bar', 'foo never became "bar"');
});
```

By default, `waitUntil` will poll every `50ms` and time out after `1000ms`. Those options can be configured:

```javascript
await waitUntil(() => elem.condition, {
await waitUntil(() => elem.condition, 'Condition was never met', {
interval: 10,
timeout: 2000
});
Expand Down

0 comments on commit 243b065

Please sign in to comment.