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
+13-12Lines changed: 13 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
---
2
2
title: 'testing'
3
-
head_title: 'testing'
4
3
description: 'The k6 testing library provides test assertion capabilities for both protocol and browser testing.'
5
4
weight: 00
6
5
---
@@ -10,7 +9,7 @@ weight: 00
10
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.
11
10
12
11
{{< admonition type="note" >}}
13
-
The k6 testing library source code can be found on [GitHub](https://github.com/grafana/k6-jslib-testing).
12
+
The k6 testing library source code is available on [GitHub](https://github.com/grafana/k6-jslib-testing).
14
13
{{< /admonition >}}
15
14
16
15
## Features
@@ -23,7 +22,7 @@ The k6 testing library source code can be found on [GitHub](https://github.com/g
23
22
24
23
## Usage
25
24
26
-
To use the testing library in your k6 script, import it in your tests, directly from the jslib repository:
25
+
To use the testing library in your k6 script, import it in your tests directly from the jslib repository:
Synchronous assertions that evaluate immediately - perfect for testing static values, API responses, and any scenario where the expected condition should be true at the moment of evaluation.
Asynchronous assertions that automatically retry until conditions become true or timeout - ideal for browser testing, dynamic content, and any scenario where conditions may change over time.
94
+
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.
98
99
99
100
## API Reference
100
101
101
102
| Function | Description |
102
103
| --- | --- |
103
-
|[expect()]({{< relref "./expect" >}}) | Main assertion function |
Copy file name to clipboardExpand all lines: docs/sources/k6/next/javascript-api/jslib/testing/configure.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ weight: 20
7
7
8
8
# expect.configure()
9
9
10
-
The `expect.configure()` method creates a new configured expect instance with custom behavior for the k6 testing library, including timeouts, display options, and soft assertion behavior. The original expect instance remains unchanged.
10
+
The `expect.configure()` method creates a new configured `expect` instance with custom behavior for the k6 testing library, including timeouts, display options, and soft assertion behavior. The original `expect` instance remains unchanged.
The `expect.configure()` method creates a new expect instance with custom configuration options. This new instance can be used in place of the default expect function, and will apply the specified configuration to all assertions made with it. The original expect instance remains unchanged and continues to use the default configuration.
43
43
44
-
### Timeout Configuration
44
+
### Timeout configuration
45
45
46
46
The `timeout` option controls how long retrying assertions will wait for a condition to become true:
By default, failed assertions will terminate the test execution. The k6 testing library also supports soft assertions: failed soft assertions do not terminate the test execution, but mark the test as failed, leading k6 to eventually exit with code `110`.
77
+
By default, failed assertions will terminate the test execution. Soft assertions, on the other hand, don't terminate the test execution when they fail, but mark the test as failed, leading k6 to eventually exit with code `110`.
79
78
80
79
```javascript
81
80
importexecfrom"k6/execution";
@@ -161,7 +160,7 @@ export default async function () {
Copy file name to clipboardExpand all lines: docs/sources/k6/next/javascript-api/jslib/testing/non-retrying-assertions/_index.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
---
2
2
title: 'Non-Retrying Assertions'
3
-
head_title: 'Non-Retrying Assertions'
4
3
description: 'Synchronous assertions that evaluate immediately'
5
4
weight: 40
6
5
---
@@ -9,7 +8,6 @@ weight: 40
9
8
10
9
Non-retrying assertions are synchronous assertions that allow to test any conditions, but do not auto-retry. They are ideal for testing static values, API responses, and any scenario where the expected condition should be true at the moment of evaluation.
11
10
12
-
## Overview
13
11
14
12
Non-retrying assertions differ from [retrying assertions](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions) in that they:
15
13
@@ -44,7 +42,7 @@ Non-retrying assertions are best suited for:
44
42
-**Known state verification** - Checking values that should be immediately available
0 commit comments