Skip to content

Commit a90f418

Browse files
heitortsergentankur22
authored andcommitted
Remove head_title properties
Add eslint-skip blocks
1 parent 2adaa5f commit a90f418

33 files changed

+555
-505
lines changed

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

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
---
22
title: 'expect.configure()'
3-
head_title: 'expect.configure(options)'
43
description: 'Configure global assertion behavior for the k6 testing library'
54
weight: 20
65
---
76

87
# expect.configure()
98

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.
9+
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.
1110

12-
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.
11+
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.
1312

1413
The imported `expect` instance remains unchanged and continues to use the default configuration, allowing different assertion configurations to co-exist within a test.
1514

1615
## Syntax
1716

17+
<!-- eslint-skip -->
18+
1819
```javascript
19-
const configuredExpect = expect.configure(options)
20+
const configuredExpect = expect.configure(options);
2021
```
2122

2223
## Parameters
2324

24-
| Parameter | Type | Description |
25-
| --- | --- | --- |
26-
| options | object | Configuration options object |
25+
| Parameter | Type | Description |
26+
| --------- | ------ | ---------------------------- |
27+
| options | object | Configuration options object |
2728

2829
### Options
2930

30-
| Property | Type | Default | Description |
31-
| --- | --- | --- | --- |
32-
| timeout | number | `5000` | Default timeout in milliseconds for retrying assertions |
33-
| interval | number | `100` | Polling interval in milliseconds for retrying assertions |
34-
| colorize | boolean | `true` | Enable colorized output in assertion messages |
35-
| display | string | `"pretty"` | Output format for assertion messages (`"pretty"` or `"inline"`) |
36-
| softMode | string | `"fail"` | Soft assertion behavior (`"fail"` or `"throw"`) |
31+
| Property | Type | Default | Description |
32+
| -------- | ------- | ---------- | --------------------------------------------------------------- |
33+
| timeout | number | `5000` | Default timeout in milliseconds for retrying assertions |
34+
| interval | number | `100` | Polling interval in milliseconds for retrying assertions |
35+
| colorize | boolean | `true` | Enable colorized output in assertion messages |
36+
| display | string | `"pretty"` | Output format for assertion messages (`"pretty"` or `"inline"`) |
37+
| softMode | string | `"fail"` | Soft assertion behavior (`"fail"` or `"throw"`) |
3738

3839
## Returns
3940

40-
| Type | Description |
41-
| --- | --- |
41+
| Type | Description |
42+
| ------ | ------------------------------------------------------ |
4243
| Expect | A new expect instance with the specified configuration |
4344

4445
### Timeout configuration
@@ -50,8 +51,8 @@ import { expect } from 'https://jslib.k6.io/k6-testing/{{< param "JSLIB_TESTING_
5051

5152
// Create a configured expect instance with longer timeout for slow-loading elements
5253
const slowExpect = expect.configure({
53-
timeout: 10000, // 10 seconds
54-
interval: 500, // Check every 500ms
54+
timeout: 10000, // 10 seconds
55+
interval: 500, // Check every 500ms
5556
});
5657
```
5758

@@ -77,7 +78,7 @@ The `softMode` option controls whether failed assertions stop test execution:
7778
import { expect } from 'https://jslib.k6.io/k6-testing/{{< param "JSLIB_TESTING_VERSION" >}}/index.js';
7879

7980
// The default behavior of soft assertions is mark the test as failed, the `softMode` option
80-
// allows to configure soft assertions to throw an exception and fail the current iteration instead.
81+
// allows to configure soft assertions to throw an exception and fail the current iteration instead.
8182
const softExpect = expect.configure({
8283
softMode: 'throw',
8384
});
@@ -87,13 +88,13 @@ const softExpect = expect.configure({
8788

8889
Configuration options can also be set using environment variables:
8990

90-
| Environment Variable | Option | Description |
91-
| --- | --- | --- |
92-
| `K6_TESTING_TIMEOUT` | `timeout` | Default timeout in milliseconds |
93-
| `K6_TESTING_INTERVAL` | `interval` | Polling interval in milliseconds |
94-
| `K6_TESTING_COLORIZE` | `colorize` | Enable colored output (`true`/`false`) |
95-
| `K6_TESTING_DISPLAY` | `display` | Output format (`pretty`/`inline`) |
96-
| `K6_TESTING_SOFT_MODE` | `softMode` | Soft assertion mode (`fail`/`throw`) |
91+
| Environment Variable | Option | Description |
92+
| ---------------------- | ---------- | -------------------------------------- |
93+
| `K6_TESTING_TIMEOUT` | `timeout` | Default timeout in milliseconds |
94+
| `K6_TESTING_INTERVAL` | `interval` | Polling interval in milliseconds |
95+
| `K6_TESTING_COLORIZE` | `colorize` | Enable colored output (`true`/`false`) |
96+
| `K6_TESTING_DISPLAY` | `display` | Output format (`pretty`/`inline`) |
97+
| `K6_TESTING_SOFT_MODE` | `softMode` | Soft assertion mode (`fail`/`throw`) |
9798

9899
```bash
99100
# Set environment variables
@@ -106,6 +107,8 @@ k6 run test.js
106107

107108
### Basic Configuration
108109

110+
<!-- eslint-skip -->
111+
109112
```javascript
110113
import { expect } from 'https://jslib.k6.io/k6-testing/{{< param "JSLIB_TESTING_VERSION" >}}/index.js';
111114

@@ -114,13 +117,13 @@ const myExpect = expect.configure({
114117
timeout: 8000,
115118
interval: 200,
116119
colorize: true,
117-
display: 'pretty'
120+
display: 'pretty',
118121
});
119122

120123
export default function () {
121124
// Use the configured instance
122125
myExpect(response.status).toBe(200);
123-
126+
124127
// Original expect instance still works with defaults
125128
expect(response.status).toBe(200);
126129
}
@@ -134,14 +137,14 @@ import { expect } from 'https://jslib.k6.io/k6-testing/{{< param "JSLIB_TESTING_
134137

135138
// Create expect instance configured for browser testing with longer timeouts
136139
const browserExpect = expect.configure({
137-
timeout: 15000, // Longer timeout for browser operations
138-
interval: 500, // Less frequent polling
140+
timeout: 15000, // Longer timeout for browser operations
141+
interval: 500, // Less frequent polling
139142
});
140143

141144
export default async function () {
142145
const page = browser.newPage();
143146
await page.goto('https://test.k6.io');
144-
147+
145148
// Will wait up to 15 seconds for element to be visible
146149
await browserExpect(page.locator('h1')).toBeVisible();
147150
}
@@ -154,9 +157,9 @@ import { expect } from 'https://jslib.k6.io/k6-testing/{{< param "JSLIB_TESTING_
154157

155158
// Create expect instance configured for CI environment
156159
const ciExpect = expect.configure({
157-
colorize: false, // Disable colors in CI logs
160+
colorize: false, // Disable colors in CI logs
158161
display: 'inline', // inline output for CI
159-
timeout: 30000, // Longer timeout for CI environment
162+
timeout: 30000, // Longer timeout for CI environment
160163
});
161164
```
162165

@@ -178,6 +181,8 @@ const envExpect = expect.configure({
178181

179182
### Multiple Configured Instances
180183

184+
<!-- eslint-skip -->
185+
181186
```javascript
182187
import { expect } from 'https://jslib.k6.io/k6-testing/{{< param "JSLIB_TESTING_VERSION" >}}/index.js';
183188

@@ -187,16 +192,16 @@ export default function () {
187192
timeout: 1000,
188193
interval: 50,
189194
});
190-
195+
191196
const slowExpect = expect.configure({
192197
timeout: 30000,
193198
softMode: 'continue',
194199
});
195-
200+
196201
// Use appropriate instance for each test
197202
fastExpect(quickOperation()).toBe(true);
198203
slowExpect(slowOperation()).toBe(true);
199-
204+
200205
// Original expect instance still available
201206
expect(normalOperation()).toBe(true);
202207
}
@@ -215,12 +220,12 @@ const softExpect = expect.configure({
215220

216221
export default function () {
217222
const response = http.get('https://test-api.k6.io/public/crocodiles/1/');
218-
223+
219224
// These assertions will not stop test execution on failure
220225
softExpect(response.status).toBe(200);
221226
softExpect(response.json()).toHaveProperty('name');
222227
softExpect(response.json()).toHaveProperty('age');
223-
228+
224229
// Test continues even if assertions fail
225230
console.log('Test completed');
226231
}

0 commit comments

Comments
 (0)