grafana / jslib.k6.io

Repository of useful utility libs for k6 scripts
https://jslib.k6.io/
GNU Affero General Public License v3.0
52 stars 21 forks source link

Add async `check` helper #125

Closed inancgumus closed 2 weeks ago

inancgumus commented 4 months ago

What

Add a helper that supports asynchronous check functionality.

Example (currently, it does not work):

check(page, {
    'checked': async p => await p.locator('.checked').isChecked(),
});

We use the following code until we add async check support:

const isChecked = await p.locator('.checked').isChecked();
check(page, {
    'checked': p => isChecked,
});

Why

We're converting the browser's sync methods to async. We noticed that check intentionally does not allow async methods in it. This issue isn't great for user experience (also considering the browser's 150ish methods will be async). Can we find a way to make this more user-friendly?

### Tasks
- [ ] https://github.com/grafana/k6-jslib-utils/pull/13
- [x] Upload the library
- [ ] https://github.com/grafana/k6-docs/issues/1725
- [x] k6: Add it to release notes
inancgumus commented 2 weeks ago

Updating k6-docs will be tackled in another issue: grafana/k6-docs#1725