From 7f61b5abc6db7e9440f7ee360cf5b469264b9849 Mon Sep 17 00:00:00 2001 From: Heitor Tashiro Sergent Date: Thu, 7 Nov 2024 14:10:49 -0600 Subject: [PATCH] Update group page to include link to utils check function (#1803) * Update group page to include link to utils check function This link is referenced from a k6 error message when using the check function, and it now includes a link to where users can find the correct information. * Remove duplicate description * Apply to v0.54 and v0.53 --- .../k6/next/javascript-api/k6/group.md | 19 +++++++++++++------ .../k6/v0.53.x/javascript-api/k6/group.md | 19 +++++++++++++------ .../k6/v0.54.x/javascript-api/k6/group.md | 19 +++++++++++++------ 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/docs/sources/k6/next/javascript-api/k6/group.md b/docs/sources/k6/next/javascript-api/k6/group.md index 3038357e9..adac288fc 100644 --- a/docs/sources/k6/next/javascript-api/k6/group.md +++ b/docs/sources/k6/next/javascript-api/k6/group.md @@ -1,11 +1,16 @@ --- title: 'group( name, fn )' description: 'Runs code inside a group. Used to organize results in a test.' -description: 'Runs code inside a group. Used to organize results in a test.' --- # group( name, fn ) +{{< admonition type="note" >}} + +For details about using the `check()` function with async values, refer to the jslib utils [check](https://grafana.com/docs/k6//javascript-api/jslib/utils/check/). + +{{< /admonition >}} + Run code inside a group. Groups are used to organize results in a test. | Parameter | Type | Description | @@ -19,18 +24,20 @@ Run code inside a group. Groups are used to organize results in a test. | ---- | ------------------------- | | any | The return value of _fn_. | +## Limitations + {{< admonition type="warning" >}} Avoid using `group` with async functions or asynchronous code. -If you do, k6 might apply tags in a way that is unreliable or unintuitive. +If you do, k6 might apply tags in an unreliable or unintuitive way. -If you start promise chains or even use `await` within `group`, some code within the group will be waited for and tagged with the proper `group` tag, but others won't be. +{{< /admonition >}} -To avoid confusion, `async` functions are forbidden as `group()` arguments. This still lets users make and chain promises within a group, but doing so is unsupported and not recommended. +If you start promise chains or use `await` within `group`, some code within the group will be waited for and tagged with the proper `group` tag, but others won't be. -For more information, refer to [k6 #2728](https://github.com/grafana/k6/issues/2728), which tracks possible solutions and provides detailed explanations. +To avoid confusion, `async` functions are forbidden as `group()` arguments. That still lets users make and chain promises within a group, but doing so is unsupported and not recommended. -{{< /admonition >}} +For more information, refer to [k6 #2728](https://github.com/grafana/k6/issues/2728), which tracks possible solutions and provides detailed explanations. ### Example diff --git a/docs/sources/k6/v0.53.x/javascript-api/k6/group.md b/docs/sources/k6/v0.53.x/javascript-api/k6/group.md index 3038357e9..adac288fc 100644 --- a/docs/sources/k6/v0.53.x/javascript-api/k6/group.md +++ b/docs/sources/k6/v0.53.x/javascript-api/k6/group.md @@ -1,11 +1,16 @@ --- title: 'group( name, fn )' description: 'Runs code inside a group. Used to organize results in a test.' -description: 'Runs code inside a group. Used to organize results in a test.' --- # group( name, fn ) +{{< admonition type="note" >}} + +For details about using the `check()` function with async values, refer to the jslib utils [check](https://grafana.com/docs/k6//javascript-api/jslib/utils/check/). + +{{< /admonition >}} + Run code inside a group. Groups are used to organize results in a test. | Parameter | Type | Description | @@ -19,18 +24,20 @@ Run code inside a group. Groups are used to organize results in a test. | ---- | ------------------------- | | any | The return value of _fn_. | +## Limitations + {{< admonition type="warning" >}} Avoid using `group` with async functions or asynchronous code. -If you do, k6 might apply tags in a way that is unreliable or unintuitive. +If you do, k6 might apply tags in an unreliable or unintuitive way. -If you start promise chains or even use `await` within `group`, some code within the group will be waited for and tagged with the proper `group` tag, but others won't be. +{{< /admonition >}} -To avoid confusion, `async` functions are forbidden as `group()` arguments. This still lets users make and chain promises within a group, but doing so is unsupported and not recommended. +If you start promise chains or use `await` within `group`, some code within the group will be waited for and tagged with the proper `group` tag, but others won't be. -For more information, refer to [k6 #2728](https://github.com/grafana/k6/issues/2728), which tracks possible solutions and provides detailed explanations. +To avoid confusion, `async` functions are forbidden as `group()` arguments. That still lets users make and chain promises within a group, but doing so is unsupported and not recommended. -{{< /admonition >}} +For more information, refer to [k6 #2728](https://github.com/grafana/k6/issues/2728), which tracks possible solutions and provides detailed explanations. ### Example diff --git a/docs/sources/k6/v0.54.x/javascript-api/k6/group.md b/docs/sources/k6/v0.54.x/javascript-api/k6/group.md index 3038357e9..adac288fc 100644 --- a/docs/sources/k6/v0.54.x/javascript-api/k6/group.md +++ b/docs/sources/k6/v0.54.x/javascript-api/k6/group.md @@ -1,11 +1,16 @@ --- title: 'group( name, fn )' description: 'Runs code inside a group. Used to organize results in a test.' -description: 'Runs code inside a group. Used to organize results in a test.' --- # group( name, fn ) +{{< admonition type="note" >}} + +For details about using the `check()` function with async values, refer to the jslib utils [check](https://grafana.com/docs/k6//javascript-api/jslib/utils/check/). + +{{< /admonition >}} + Run code inside a group. Groups are used to organize results in a test. | Parameter | Type | Description | @@ -19,18 +24,20 @@ Run code inside a group. Groups are used to organize results in a test. | ---- | ------------------------- | | any | The return value of _fn_. | +## Limitations + {{< admonition type="warning" >}} Avoid using `group` with async functions or asynchronous code. -If you do, k6 might apply tags in a way that is unreliable or unintuitive. +If you do, k6 might apply tags in an unreliable or unintuitive way. -If you start promise chains or even use `await` within `group`, some code within the group will be waited for and tagged with the proper `group` tag, but others won't be. +{{< /admonition >}} -To avoid confusion, `async` functions are forbidden as `group()` arguments. This still lets users make and chain promises within a group, but doing so is unsupported and not recommended. +If you start promise chains or use `await` within `group`, some code within the group will be waited for and tagged with the proper `group` tag, but others won't be. -For more information, refer to [k6 #2728](https://github.com/grafana/k6/issues/2728), which tracks possible solutions and provides detailed explanations. +To avoid confusion, `async` functions are forbidden as `group()` arguments. That still lets users make and chain promises within a group, but doing so is unsupported and not recommended. -{{< /admonition >}} +For more information, refer to [k6 #2728](https://github.com/grafana/k6/issues/2728), which tracks possible solutions and provides detailed explanations. ### Example