Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docs for new async check function in k6-utils #1694

Merged
merged 3 commits into from
Aug 21, 2024

Conversation

allansson
Copy link
Collaborator

What?

This PR documents the new async check function in k6-utils.

Checklist

  • I have used a meaningful title for the PR.
  • I have described the changes I've made in the "What?" section above.
  • I have performed a self-review of my changes.
  • I have run the npm start command locally and verified that the changes look good.
  • I have made my changes in the docs/sources/next folder of the documentation.
  • I have reflected my changes in the docs/sources/v{most_recent_release} folder of the documentation.

Related PR(s)/Issue(s)

Issue: grafana/jslib.k6.io#125

@allansson allansson marked this pull request as ready for review August 16, 2024 10:29
Copy link
Collaborator

@heitortsergent heitortsergent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just made some small edits, everything else looks good. Thanks for adding this to the docs! 🤓 :shipit:

Comment on lines 3 to 4
description: 'Runs one or more checks on a value and generates a pass/fail result but does not throw errors or otherwise interrupt execution upon failure.'
description: 'Runs one or more checks on a value and generates a pass/fail result but does not throw errors or otherwise interrupt execution upon failure.'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: 'Runs one or more checks on a value and generates a pass/fail result but does not throw errors or otherwise interrupt execution upon failure.'
description: 'Runs one or more checks on a value and generates a pass/fail result but does not throw errors or otherwise interrupt execution upon failure.'
description: 'The jslib check function runs one or more checks on a value and generates a pass/fail result, but does not throw errors or interrupt test execution upon failure. It supports async values.'

Removing the duplicate description, and some small edits to it. I think it's useful for us to add the async support here.


# check( val, sets, [tags] )

This is a drop-in replacement for the built-in [check](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6/check/) with support for async values. Any `Promise`s will be awaited and the result will be reported once the operation has completed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is a drop-in replacement for the built-in [check](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6/check/) with support for async values. Any `Promise`s will be awaited and the result will be reported once the operation has completed.
The `check` function is a drop-in replacement for the built-in [check](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6/check/), with added support for async values. Any `Promise`s will be awaited, and the result is reported once the operation has been completed.

| Parameter | Type | Description |
| --------------- | ---------------------- | ---------------------------------------------------------------------------------------- |
| val | any | Value to test. |
| sets | Record<string, any> | Tests (checks) to run on the value. Functions will be called. `Promise`s will be awaited |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| sets | Record<string, any> | Tests (checks) to run on the value. Functions will be called. `Promise`s will be awaited |
| sets | Record<string, any> | Tests (checks) to run on the value. Functions will be called. `Promise`s will be awaited. |


| Type | Description |
| ---------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Promise<boolean> | boolean | `true` if all checks have succeeded, `false` otherwise. If any of the checked values was a `Promise`, the result will be wrapped in a `Promise`. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Promise<boolean> | boolean | `true` if all checks have succeeded, `false` otherwise. If any of the checked values was a `Promise`, the result will be wrapped in a `Promise`. |
| Promise<boolean> | boolean | `true` if all checks have succeeded, `false` otherwise. If any of the checked values was a `Promise`, the result is wrapped in a `Promise`. |

@allansson allansson merged commit 6f1bb3b into main Aug 21, 2024
5 checks passed
@allansson allansson deleted the add-docs-for-async-check branch August 21, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants