Skip to content

Commit

Permalink
Improve async check notes
Browse files Browse the repository at this point in the history
Co-authored-by: Ankur <ankur.agarwal@grafana.com>
  • Loading branch information
inancgumus and ankur22 authored Sep 19, 2024
1 parent cac0382 commit af29a66
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions release notes/v0.54.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ await page.setChecked('#checkbox', false); // uncheck the checkbox

### Async `check` function utility [`k6-utils#13`](https://github.com/grafana/k6-jslib-utils/pull/13)

Writing clean code can be cumbersome using [the k6 `check` function](https://grafana.com/docs/k6/latest/javascript-api/k6/check/) with async code because the `check` function does not support asynchronous checks. One potential solution is to declare a temporary variable and wait for the value first, then check the result later. However, this approach can clutter the code with single-use declarations and unnecessary variable names:
Writing concise code can be difficult when using [the k6 `check` function](https://grafana.com/docs/k6/latest/javascript-api/k6/check/) with async code since it doesn't support async APIs. A solution that we have suggested so far is to declare a temporary variable, wait for the value that is to be checked, and then check the result later. However, this approach can clutter the code with single-use declarations and unnecessary variable names, e.g.:

```javascript
const checked = await p.locator('.checked').isChecked();

check(page, {
'checked': p => checked,
check(checked, {
'checked': c => c,
});
```

Expand Down

0 comments on commit af29a66

Please sign in to comment.