Skip to content

Commit 2c9f5bc

Browse files
committed
Update v52-53 for async check
1 parent 856ffde commit 2c9f5bc

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

docs/sources/v0.52.x/using-k6-browser/recommended-practices/hybrid-approach-to-performance.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ The code below shows an example of combining a browser and HTTP test in a single
1919
{{< code >}}
2020

2121
```javascript
22-
import http from 'k6/http';
2322
import { browser } from 'k6/browser';
2423
import { check } from 'https://jslib.k6.io/k6-utils/1.5.0/index.js';
2524
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
25+
import http from 'k6/http';
2626

2727
const BASE_URL = __ENV.BASE_URL || 'https://quickpizza.grafana.com';
2828

@@ -87,7 +87,7 @@ export async function checkFrontend() {
8787
await page.goto(BASE_URL);
8888

8989
check(page.locator('h1'), {
90-
header: async lo => await lo.textContent() == 'Looking to break out of your pizza routine?'
90+
'header': async lo => await lo.textContent() == 'Looking to break out of your pizza routine?'
9191
});
9292

9393
await Promise.all([
@@ -97,7 +97,7 @@ export async function checkFrontend() {
9797
await page.screenshot({ path: `screenshots/${__ITER}.png` });
9898

9999
await check(page.locator('div#recommendations'), {
100-
recommendation: async lo => await lo.textContent() != '',
100+
'recommendation': async lo => await lo.textContent() != '',
101101
});
102102
} finally {
103103
await page.close();
@@ -130,9 +130,8 @@ To find out more information about injecting faults to your service, check out t
130130
{{< code >}}
131131

132132
```javascript
133-
import http from 'k6/http';
134-
import { check } from 'k6';
135133
import { browser } from 'k6/browser';
134+
import { check } from 'https://jslib.k6.io/k6-utils/1.5.0/index.js';
136135
import { ServiceDisruptor } from 'k6/x/disruptor';
137136

138137
const BASE_URL = __ENV.BASE_URL;
@@ -187,7 +186,7 @@ export async function checkFrontend() {
187186
try {
188187
await page.goto(BASE_URL);
189188
check(page.locator('h1'), {
190-
header: async lo => await lo.textContent() == 'Looking to break out of your pizza routine?'
189+
'header': async lo => await lo.textContent() == 'Looking to break out of your pizza routine?'
191190
});
192191

193192
await Promise.all([

docs/sources/v0.53.x/javascript-api/k6-browser/page/waitforfunction.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ Returns when the `pageFunction` returns a truthy value.
99

1010
<TableWithNestedRows>
1111

12-
| Parameter | Type | Default | Description |
13-
| --------------- | --------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14-
| pageFunction | function | | Function to be evaluated in the page context. |
15-
| arg | string | `''` | Optional argument to pass to `pageFunction` |
16-
| options | object | `null` | |
17-
| options.polling | number or `raf` | `raf` | If `polling` is `'raf'`, then `pageFunction` is constantly executed in `requestAnimationFrame` callback. If `polling` is a number, then it is treated as an interval in milliseconds at which the function would be executed. |
12+
| Parameter | Type | Default | Description |
13+
| --------------- | --------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14+
| pageFunction | function | | Function to be evaluated in the page context. |
15+
| arg | string | `''` | Optional argument to pass to `pageFunction` |
16+
| options | object | `null` | |
17+
| options.polling | number or `raf` | `raf` | If `polling` is `'raf'`, then `pageFunction` is constantly executed in `requestAnimationFrame` callback. If `polling` is a number, then it is treated as an interval in milliseconds at which the function would be executed. |
1818
| options.timeout | number | `30000` | Maximum time in milliseconds. Pass `0` to disable the timeout. Default is overridden by the `setDefaultTimeout` option on [BrowserContext](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/browsercontext/) or [Page](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/page/). |
1919

2020
</TableWithNestedRows>
2121

2222
### Returns
2323

24-
| Type | Description |
25-
| ------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
24+
| Type | Description |
25+
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
2626
| Promise<[JSHandle](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/jshandle/)> | The `JSHandle` instance associated with the page. |
2727

2828
### Example

docs/sources/v0.53.x/using-k6-browser/recommended-practices/hybrid-approach-to-performance.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ The code below shows an example of combining a browser and HTTP test in a single
1919
{{< code >}}
2020

2121
```javascript
22-
import http from 'k6/http';
2322
import { browser } from 'k6/browser';
2423
import { check } from 'https://jslib.k6.io/k6-utils/1.5.0/index.js';
2524
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
25+
import http from 'k6/http';
2626

2727
const BASE_URL = __ENV.BASE_URL || 'https://quickpizza.grafana.com';
2828

@@ -87,7 +87,7 @@ export async function checkFrontend() {
8787
await page.goto(BASE_URL);
8888

8989
check(page.locator('h1'), {
90-
header: async lo => await lo.textContent() == 'Looking to break out of your pizza routine?'
90+
'header': async lo => await lo.textContent() == 'Looking to break out of your pizza routine?'
9191
});
9292

9393
await Promise.all([
@@ -97,7 +97,7 @@ export async function checkFrontend() {
9797
await page.screenshot({ path: `screenshots/${__ITER}.png` });
9898

9999
await check(page.locator('div#recommendations'), {
100-
recommendation: async lo => await lo.textContent() != '',
100+
'recommendation': async lo => await lo.textContent() != '',
101101
});
102102
} finally {
103103
await page.close();
@@ -130,9 +130,8 @@ To find out more information about injecting faults to your service, check out t
130130
{{< code >}}
131131

132132
```javascript
133-
import http from 'k6/http';
134-
import { check } from 'k6';
135133
import { browser } from 'k6/browser';
134+
import { check } from 'https://jslib.k6.io/k6-utils/1.5.0/index.js';
136135
import { ServiceDisruptor } from 'k6/x/disruptor';
137136

138137
const BASE_URL = __ENV.BASE_URL;
@@ -187,7 +186,7 @@ export async function checkFrontend() {
187186
try {
188187
await page.goto(BASE_URL);
189188
check(page.locator('h1'), {
190-
header: async lo => await lo.textContent() == 'Looking to break out of your pizza routine?'
189+
'header': async lo => await lo.textContent() == 'Looking to break out of your pizza routine?'
191190
});
192191

193192
await Promise.all([

0 commit comments

Comments
 (0)