Skip to content

Commit db019d3

Browse files
oleiadeheitortsergent
authored andcommitted
Apply suggestions from code review
Co-authored-by: Heitor Tashiro Sergent <[email protected]>
1 parent 76a0305 commit db019d3

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

docs/sources/k6/next/javascript-api/jslib/testing/_index.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: 'testing'
3-
head_title: 'testing'
43
description: 'The k6 testing library provides test assertion capabilities for both protocol and browser testing.'
54
weight: 00
65
---
@@ -10,7 +9,7 @@ weight: 00
109
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.
1110

1211
{{< 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).
1413
{{< /admonition >}}
1514

1615
## Features
@@ -23,7 +22,7 @@ The k6 testing library source code can be found on [GitHub](https://github.com/g
2322

2423
## Usage
2524

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:
2726

2827
```javascript
2928
import { expect } from 'https://jslib.k6.io/k6-testing/{{< param "JSLIB_AWS_VERSION" >}}/index.js';
@@ -71,7 +70,7 @@ export default async function () {
7170

7271
## Configuration
7372

74-
Create configured expect instances for custom behavior:
73+
Create configured `expect` instances for custom behavior:
7574

7675
```javascript
7776
import { expect } from 'https://jslib.k6.io/k6-testing/{{< param "JSLIB_AWS_VERSION" >}}/index.js';
@@ -90,17 +89,19 @@ const myExpect = expect.configure({
9089

9190
The testing library provides two types of assertions:
9291

93-
### [Non-Retrying Assertions]({{< relref "./non-retrying-assertions" >}})
94-
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.
92+
### [Non-Retrying Assertions](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/expect/non-retrying-assertions/)
9593

96-
### [Retrying Assertions]({{< relref "./retrying-assertions" >}})
97-
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.
95+
96+
### [Retrying Assertions]((https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/expect/retrying-assertions/)
97+
98+
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.
9899

99100
## API Reference
100101

101102
| Function | Description |
102103
| --- | --- |
103-
| [expect()]({{< relref "./expect" >}}) | Main assertion function |
104-
| [expect.configure()]({{< relref "./configure" >}}) | Create configured expect instances |
105-
| [Non-Retrying Assertions]({{< relref "./non-retrying-assertions" >}}) | Synchronous assertions for immediate evaluation |
106-
| [Retrying Assertions]({{< relref "./retrying-assertions" >}}) | Asynchronous assertions for dynamic content |
104+
| [expect()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/expect) | Main assertion function |
105+
| [expect.configure()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/configure) | Create configured expect instances |
106+
| [Non-Retrying Assertions](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/non-retrying-assertions) | Synchronous assertions for immediate evaluation |
107+
| [Retrying Assertions](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing/retrying-assertions) | Asynchronous assertions for dynamic content |

docs/sources/k6/next/javascript-api/jslib/testing/configure.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ weight: 20
77

88
# expect.configure()
99

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.
1111

1212
## Syntax
1313

@@ -27,7 +27,7 @@ const configuredExpect = expect.configure(options)
2727
| --- | --- | --- | --- |
2828
| timeout | number | `5000` | Default timeout in milliseconds for retrying assertions |
2929
| interval | number | `100` | Polling interval in milliseconds for retrying assertions |
30-
| colorize | boolean | `true` | Enable colored output in assertion messages |
30+
| colorize | boolean | `true` | Enable colorized output in assertion messages |
3131
| display | string | `"pretty"` | Output format for assertion messages (`"pretty"` or `"inline"`) |
3232
| softMode | string | `"fail"` | Soft assertion behavior (`"fail"` or `"throw"`) |
3333

@@ -41,7 +41,7 @@ const configuredExpect = expect.configure(options)
4141

4242
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.
4343

44-
### Timeout Configuration
44+
### Timeout configuration
4545

4646
The `timeout` option controls how long retrying assertions will wait for a condition to become true:
4747

docs/sources/k6/next/javascript-api/jslib/testing/expect.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: 'expect()'
3-
head_title: 'expect()'
4-
description: 'Main assertion function for creating expectations in k6 tests'
3+
description: 'expect() is the main function for creating assertions in k6 tests'
54
weight: 10
65
---
76

@@ -75,7 +74,7 @@ expect('hello').not.toContain('world');
7574

7675
### Soft Assertions
7776

78-
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`.
7978

8079
```javascript
8180
import exec from "k6/execution";
@@ -161,7 +160,7 @@ export default async function () {
161160
}
162161
```
163162

164-
## Available Assertion Methods
163+
## Assertion methods
165164

166165
### Non-Retrying Assertions
167166

docs/sources/k6/next/javascript-api/jslib/testing/non-retrying-assertions/_index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: 'Non-Retrying Assertions'
3-
head_title: 'Non-Retrying Assertions'
43
description: 'Synchronous assertions that evaluate immediately'
54
weight: 40
65
---
@@ -9,7 +8,6 @@ weight: 40
98

109
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.
1110

12-
## Overview
1311

1412
Non-retrying assertions differ from [retrying assertions](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6-testing/retrying-assertions) in that they:
1513

@@ -44,7 +42,7 @@ Non-retrying assertions are best suited for:
4442
- **Known state verification** - Checking values that should be immediately available
4543

4644

47-
## Available Non-Retrying Assertions
45+
## Non-retrying assertions methods
4846

4947
### Equality Assertions
5048

0 commit comments

Comments
 (0)