You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sources/k6/next/javascript-api/jslib/testing/_index.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ weight: 00
6
6
7
7
# testing
8
8
9
-
The k6 testing library provides assertion capabilities for both protocol and browser testing, and draws inspiration from Playwright's test API design. The entire library is centered around the [`expect()`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/expect) function, which can be configured for convenience.
9
+
The k6 testing library provides assertion capabilities for both protocol and browser testing, and draws inspiration from Playwright's test API design. The entire library is centered around the [`expect()`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/expect) function, which can be configured for convenience.
10
10
11
11
{{< admonition type="note" >}}
12
12
The k6 testing library source code is available on [GitHub](https://github.com/grafana/k6-jslib-testing).
@@ -16,9 +16,9 @@ The k6 testing library source code is available on [GitHub](https://github.com/g
16
16
17
17
-**Playwright-inspired assertions**: API designed with patterns inspired by Playwright's testing approach
18
18
-**[Protocol and browser testing](#demo)**: Works with both HTTP/API testing and browser automation
19
-
-**[Auto-retrying assertions](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/expect#retrying-assertions)**: Automatically retry assertions until they pass or timeout
20
-
-**[Soft assertions](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/expect#soft-assertions)**: Continue test execution even after assertion failures
21
-
-**[Configurable timeouts](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/configure)**: Customizable timeout and polling intervals
19
+
-**[Auto-retrying assertions](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/expect#retrying-assertions)**: Automatically retry assertions until they pass or timeout
20
+
-**[Soft assertions](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/expect#soft-assertions)**: Continue test execution even after assertion failures
21
+
-**[Configurable timeouts](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/configure)**: Customizable timeout and polling intervals
22
22
23
23
## Usage
24
24
@@ -114,7 +114,7 @@ The testing library provides two types of assertions:
114
114
115
115
Synchronous assertions that evaluate immediately. These are ideal for testing static values, API responses, and scenarios where the expected condition should be true at the moment of evaluation.
Asynchronous assertions that automatically retry until conditions become true or timeout. These are suitable for browser testing, dynamic content, and scenarios where conditions may change over time.
|[toBe(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobe)| Exact equality using Object.is() |
201
-
|[toBeCloseTo(expected, precision?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobecloseto)| Floating point comparison |
202
-
|[toBeDefined()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobedefined)| Value is not undefined |
203
-
|[toBeFalsy()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobefalsy)| Value is falsy |
204
-
|[toBeGreaterThan(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobegreaterthan)| Greater than comparison |
205
-
|[toBeGreaterThanOrEqual(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobegreaterthanorequal)| Greater than or equal comparison |
206
-
|[toBeInstanceOf(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobeinstanceof)| Value is an instance of a class |
207
-
|[toBeLessThan(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobelessthan)| Less than comparison |
208
-
|[toBeLessThanOrEqual(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobelessthanorequal)| Less than or equal comparison |
209
-
|[toBeNaN()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobenan)| Value is NaN |
210
-
|[toBeNull()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobenull)| Value is null |
211
-
|[toBeTruthy()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobetruthy)| Value is truthy |
212
-
|[toBeUndefined()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tobeundefined)| Value is undefined |
213
-
|[toContain(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tocontain)| Array/string contains value |
214
-
|[toContainEqual(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tocontainorequal)| Array or Set contains a similar element |
215
-
|[toEqual(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/toequal)| Deep equality comparison |
216
-
|[toHaveLength(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tohavelength)| Value has a expected length |
217
-
|[toHaveProperty(path, expected?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/non-retrying-assertions/tohaveproperty)| Property at provided path exists in the object and optionally checks that it is equal to expected |
200
+
|[toBe(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobe)| Exact equality using Object.is() |
201
+
|[toBeCloseTo(expected, precision?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobecloseto)| Floating point comparison |
202
+
|[toBeDefined()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobedefined)| Value is not undefined |
203
+
|[toBeFalsy()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobefalsy)| Value is falsy |
204
+
|[toBeGreaterThan(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobegreaterthan)| Greater than comparison |
205
+
|[toBeGreaterThanOrEqual(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobegreaterthanorequal)| Greater than or equal comparison |
206
+
|[toBeInstanceOf(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobeinstanceof)| Value is an instance of a class |
207
+
|[toBeLessThan(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobelessthan)| Less than comparison |
208
+
|[toBeLessThanOrEqual(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobelessthanorequal)| Less than or equal comparison |
209
+
|[toBeNaN()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobenan)| Value is NaN |
210
+
|[toBeNull()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobenull)| Value is null |
211
+
|[toBeTruthy()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobetruthy)| Value is truthy |
212
+
|[toBeUndefined()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tobeundefined)| Value is undefined |
213
+
|[toContain(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tocontain)| Array/string contains value |
214
+
|[toContainEqual(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tocontainorequal)| Array or Set contains a similar element |
215
+
|[toEqual(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/toequal)| Deep equality comparison |
216
+
|[toHaveLength(expected)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tohavelength)| Value has a expected length |
217
+
|[toHaveProperty(path, expected?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions/tohaveproperty)| Property at provided path exists in the object and optionally checks that it is equal to expected |
|[toBeChecked(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tobechecked)| Checkbox is checked |
224
-
|[toBeDisabled(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tobedisabled)| Element is disabled |
225
-
|[toBeEditable(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tobeeditable)| Element is editable |
226
-
|[toBeEnabled(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tobeenabled)| Element is enabled |
227
-
|[toBeHidden(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tobehidden)| Element is hidden |
228
-
|[toBeVisible(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tobevisible)| Element is visible |
229
-
|[toContainText(text, options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tocontaintext)| Element contains text |
230
-
|[toHaveAttribute(attribute, value?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tohaveattribute)| Element attribute value |
231
-
|[toHaveText(text, options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tohavetext)| Element text content |
232
-
|[toHaveValue(value)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions/tohavevalue)| Input element value |
223
+
|[toBeChecked(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tobechecked)| Checkbox is checked |
224
+
|[toBeDisabled(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tobedisabled)| Element is disabled |
225
+
|[toBeEditable(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tobeeditable)| Element is editable |
226
+
|[toBeEnabled(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tobeenabled)| Element is enabled |
227
+
|[toBeHidden(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tobehidden)| Element is hidden |
228
+
|[toBeVisible(options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tobevisible)| Element is visible |
229
+
|[toContainText(text, options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tocontaintext)| Element contains text |
230
+
|[toHaveAttribute(attribute, value?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tohaveattribute)| Element attribute value |
231
+
|[toHaveText(text, options?)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tohavetext)| Element text content |
232
+
|[toHaveValue(value)](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions/tohavevalue)| Input element value |
0 commit comments