k6-cucumber-steps 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +2 -1
- package/bin/k6-cucumber-steps.js +45 -30
- package/cucumber.js +1 -1
- package/package.json +15 -19
- package/reports/cucumber-report.html +1 -1
- package/reports/load-report.json +84 -73
- package/scripts/linkReports.js +38 -91
- package/temp/load_script_6ae38e6d-f93e-443a-a516-587047b1f46b.js +65 -0
- package/reports/k6-report-2025-06-03T12-54-18-512Z.html +0 -582
- package/reports/k6-report-2025-06-03T12-54-33-806Z.html +0 -582
package/reports/load-report.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"elements": [
|
|
5
5
|
{
|
|
6
6
|
"description": "",
|
|
7
|
-
"id": "rate-limit-enforcement-for-/login-and-/bsp;
|
|
8
|
-
"keyword": "Scenario",
|
|
9
|
-
"line":
|
|
10
|
-
"name": "
|
|
7
|
+
"id": "rate-limit-enforcement-for-/login-and-/bsp;i-run-the-k6-script-for-load-testing-with-dynamic-get-requests",
|
|
8
|
+
"keyword": "Scenario Outline",
|
|
9
|
+
"line": 44,
|
|
10
|
+
"name": "I run the k6 script for load testing with dynamic GET requests",
|
|
11
11
|
"steps": [
|
|
12
12
|
{
|
|
13
13
|
"arguments": [],
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
"location": "step_definitions/load_test_steps.js:262"
|
|
19
19
|
},
|
|
20
20
|
"result": {
|
|
21
|
-
"status": "
|
|
22
|
-
"duration":
|
|
21
|
+
"status": "failed",
|
|
22
|
+
"duration": 780541,
|
|
23
|
+
"error_message": "Error: Payload file not found: /Users/paschal/personal/k6-cucumber-steps/payloads/login.json\n at CustomWorld.<anonymous> (/Users/paschal/personal/k6-cucumber-steps/step_definitions/load_test_steps.js:270:13)"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
26
|
{
|
|
@@ -31,21 +32,21 @@
|
|
|
31
32
|
"location": "step_definitions/load_test_steps.js:237"
|
|
32
33
|
},
|
|
33
34
|
"result": {
|
|
34
|
-
"status": "
|
|
35
|
-
"duration":
|
|
35
|
+
"status": "skipped",
|
|
36
|
+
"duration": 0
|
|
36
37
|
}
|
|
37
38
|
},
|
|
38
39
|
{
|
|
39
40
|
"arguments": [],
|
|
40
|
-
"keyword": "
|
|
41
|
-
"line":
|
|
42
|
-
"name": "I set a k6 script for
|
|
41
|
+
"keyword": "Given ",
|
|
42
|
+
"line": 30,
|
|
43
|
+
"name": "I set a k6 script for GET testing",
|
|
43
44
|
"match": {
|
|
44
45
|
"location": "step_definitions/load_test_steps.js:28"
|
|
45
46
|
},
|
|
46
47
|
"result": {
|
|
47
|
-
"status": "
|
|
48
|
-
"duration":
|
|
48
|
+
"status": "skipped",
|
|
49
|
+
"duration": 0
|
|
49
50
|
}
|
|
50
51
|
},
|
|
51
52
|
{
|
|
@@ -62,64 +63,68 @@
|
|
|
62
63
|
},
|
|
63
64
|
{
|
|
64
65
|
"cells": [
|
|
65
|
-
"1",
|
|
66
66
|
"10",
|
|
67
|
+
"5",
|
|
67
68
|
"rate<0.05",
|
|
68
|
-
"p(95)<
|
|
69
|
+
"p(95)<5000"
|
|
69
70
|
]
|
|
70
71
|
}
|
|
71
72
|
]
|
|
72
73
|
}
|
|
73
74
|
],
|
|
74
75
|
"keyword": "When ",
|
|
75
|
-
"line":
|
|
76
|
+
"line": 31,
|
|
76
77
|
"name": "I set to run the k6 script with the following configurations:",
|
|
77
78
|
"match": {
|
|
78
79
|
"location": "step_definitions/load_test_steps.js:40"
|
|
79
80
|
},
|
|
80
81
|
"result": {
|
|
81
|
-
"status": "
|
|
82
|
-
"duration":
|
|
82
|
+
"status": "skipped",
|
|
83
|
+
"duration": 0
|
|
83
84
|
}
|
|
84
85
|
},
|
|
85
86
|
{
|
|
86
|
-
"arguments": [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
"arguments": [
|
|
88
|
+
{
|
|
89
|
+
"content": "/get?foo1=bar1&foo2=bar2\nhttps://postman-echo.com/get?foo1=bar1&foo2=bar2",
|
|
90
|
+
"line": 35
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"keyword": "And ",
|
|
94
|
+
"line": 34,
|
|
95
|
+
"name": "I set the following endpoints used:",
|
|
90
96
|
"match": {
|
|
91
|
-
"location": "step_definitions/load_test_steps.js:
|
|
97
|
+
"location": "step_definitions/load_test_steps.js:145"
|
|
92
98
|
},
|
|
93
99
|
"result": {
|
|
94
|
-
"status": "
|
|
95
|
-
"duration":
|
|
100
|
+
"status": "skipped",
|
|
101
|
+
"duration": 0
|
|
96
102
|
}
|
|
97
103
|
},
|
|
98
104
|
{
|
|
99
105
|
"arguments": [],
|
|
100
106
|
"keyword": "When ",
|
|
101
|
-
"line":
|
|
102
|
-
"name": "I set the authentication type to \"
|
|
107
|
+
"line": 39,
|
|
108
|
+
"name": "I set the authentication type to \"none\"",
|
|
103
109
|
"match": {
|
|
104
110
|
"location": "step_definitions/load_test_steps.js:226"
|
|
105
111
|
},
|
|
106
112
|
"result": {
|
|
107
|
-
"status": "
|
|
108
|
-
"duration":
|
|
113
|
+
"status": "skipped",
|
|
114
|
+
"duration": 0
|
|
109
115
|
}
|
|
110
116
|
},
|
|
111
117
|
{
|
|
112
118
|
"arguments": [],
|
|
113
119
|
"keyword": "Then ",
|
|
114
|
-
"line":
|
|
115
|
-
"name": "I see the API should handle the
|
|
120
|
+
"line": 40,
|
|
121
|
+
"name": "I see the API should handle the GET request successfully",
|
|
116
122
|
"match": {
|
|
117
123
|
"location": "step_definitions/load_test_steps.js:306"
|
|
118
124
|
},
|
|
119
125
|
"result": {
|
|
120
|
-
"status": "
|
|
121
|
-
"duration":
|
|
122
|
-
"error_message": "Error: k6 test execution failed\n at CustomWorld.<anonymous> (/Users/paschal/personal/k6-cucumber-steps/step_definitions/load_test_steps.js:334:13)"
|
|
126
|
+
"status": "skipped",
|
|
127
|
+
"duration": 0
|
|
123
128
|
}
|
|
124
129
|
}
|
|
125
130
|
],
|
|
@@ -129,18 +134,18 @@
|
|
|
129
134
|
"line": 1
|
|
130
135
|
},
|
|
131
136
|
{
|
|
132
|
-
"name": "@
|
|
133
|
-
"line":
|
|
137
|
+
"name": "@get",
|
|
138
|
+
"line": 28
|
|
134
139
|
}
|
|
135
140
|
],
|
|
136
141
|
"type": "scenario"
|
|
137
142
|
},
|
|
138
143
|
{
|
|
139
144
|
"description": "",
|
|
140
|
-
"id": "rate-limit-enforcement-for-/login-and-/bsp;
|
|
141
|
-
"keyword": "Scenario",
|
|
142
|
-
"line":
|
|
143
|
-
"name": "
|
|
145
|
+
"id": "rate-limit-enforcement-for-/login-and-/bsp;i-run-the-k6-script-for-load-testing-with-dynamic-get-requests",
|
|
146
|
+
"keyword": "Scenario Outline",
|
|
147
|
+
"line": 45,
|
|
148
|
+
"name": "I run the k6 script for load testing with dynamic GET requests",
|
|
144
149
|
"steps": [
|
|
145
150
|
{
|
|
146
151
|
"arguments": [],
|
|
@@ -151,8 +156,9 @@
|
|
|
151
156
|
"location": "step_definitions/load_test_steps.js:262"
|
|
152
157
|
},
|
|
153
158
|
"result": {
|
|
154
|
-
"status": "
|
|
155
|
-
"duration":
|
|
159
|
+
"status": "failed",
|
|
160
|
+
"duration": 92582,
|
|
161
|
+
"error_message": "Error: Payload file not found: /Users/paschal/personal/k6-cucumber-steps/payloads/login.json\n at CustomWorld.<anonymous> (/Users/paschal/personal/k6-cucumber-steps/step_definitions/load_test_steps.js:270:13)"
|
|
156
162
|
}
|
|
157
163
|
},
|
|
158
164
|
{
|
|
@@ -164,21 +170,21 @@
|
|
|
164
170
|
"location": "step_definitions/load_test_steps.js:237"
|
|
165
171
|
},
|
|
166
172
|
"result": {
|
|
167
|
-
"status": "
|
|
168
|
-
"duration":
|
|
173
|
+
"status": "skipped",
|
|
174
|
+
"duration": 0
|
|
169
175
|
}
|
|
170
176
|
},
|
|
171
177
|
{
|
|
172
178
|
"arguments": [],
|
|
173
|
-
"keyword": "
|
|
174
|
-
"line":
|
|
175
|
-
"name": "I set a k6 script for
|
|
179
|
+
"keyword": "Given ",
|
|
180
|
+
"line": 30,
|
|
181
|
+
"name": "I set a k6 script for GET testing",
|
|
176
182
|
"match": {
|
|
177
183
|
"location": "step_definitions/load_test_steps.js:28"
|
|
178
184
|
},
|
|
179
185
|
"result": {
|
|
180
|
-
"status": "
|
|
181
|
-
"duration":
|
|
186
|
+
"status": "skipped",
|
|
187
|
+
"duration": 0
|
|
182
188
|
}
|
|
183
189
|
},
|
|
184
190
|
{
|
|
@@ -195,63 +201,68 @@
|
|
|
195
201
|
},
|
|
196
202
|
{
|
|
197
203
|
"cells": [
|
|
198
|
-
"
|
|
199
|
-
"
|
|
200
|
-
"rate
|
|
201
|
-
"p(95)<
|
|
204
|
+
"5",
|
|
205
|
+
"2",
|
|
206
|
+
"rate<0.05",
|
|
207
|
+
"p(95)<5000"
|
|
202
208
|
]
|
|
203
209
|
}
|
|
204
210
|
]
|
|
205
211
|
}
|
|
206
212
|
],
|
|
207
213
|
"keyword": "When ",
|
|
208
|
-
"line":
|
|
214
|
+
"line": 31,
|
|
209
215
|
"name": "I set to run the k6 script with the following configurations:",
|
|
210
216
|
"match": {
|
|
211
217
|
"location": "step_definitions/load_test_steps.js:40"
|
|
212
218
|
},
|
|
213
219
|
"result": {
|
|
214
|
-
"status": "
|
|
215
|
-
"duration":
|
|
220
|
+
"status": "skipped",
|
|
221
|
+
"duration": 0
|
|
216
222
|
}
|
|
217
223
|
},
|
|
218
224
|
{
|
|
219
|
-
"arguments": [
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
225
|
+
"arguments": [
|
|
226
|
+
{
|
|
227
|
+
"content": "/get?foo1=bar1&foo2=bar2\nhttps://postman-echo.com/get?foo1=bar1&foo2=bar2",
|
|
228
|
+
"line": 35
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"keyword": "And ",
|
|
232
|
+
"line": 34,
|
|
233
|
+
"name": "I set the following endpoints used:",
|
|
223
234
|
"match": {
|
|
224
|
-
"location": "step_definitions/load_test_steps.js:
|
|
235
|
+
"location": "step_definitions/load_test_steps.js:145"
|
|
225
236
|
},
|
|
226
237
|
"result": {
|
|
227
|
-
"status": "
|
|
228
|
-
"duration":
|
|
238
|
+
"status": "skipped",
|
|
239
|
+
"duration": 0
|
|
229
240
|
}
|
|
230
241
|
},
|
|
231
242
|
{
|
|
232
243
|
"arguments": [],
|
|
233
244
|
"keyword": "When ",
|
|
234
|
-
"line":
|
|
235
|
-
"name": "I set the authentication type to \"
|
|
245
|
+
"line": 39,
|
|
246
|
+
"name": "I set the authentication type to \"none\"",
|
|
236
247
|
"match": {
|
|
237
248
|
"location": "step_definitions/load_test_steps.js:226"
|
|
238
249
|
},
|
|
239
250
|
"result": {
|
|
240
|
-
"status": "
|
|
241
|
-
"duration":
|
|
251
|
+
"status": "skipped",
|
|
252
|
+
"duration": 0
|
|
242
253
|
}
|
|
243
254
|
},
|
|
244
255
|
{
|
|
245
256
|
"arguments": [],
|
|
246
257
|
"keyword": "Then ",
|
|
247
|
-
"line":
|
|
248
|
-
"name": "I see the API should handle the
|
|
258
|
+
"line": 40,
|
|
259
|
+
"name": "I see the API should handle the GET request successfully",
|
|
249
260
|
"match": {
|
|
250
261
|
"location": "step_definitions/load_test_steps.js:306"
|
|
251
262
|
},
|
|
252
263
|
"result": {
|
|
253
|
-
"status": "
|
|
254
|
-
"duration":
|
|
264
|
+
"status": "skipped",
|
|
265
|
+
"duration": 0
|
|
255
266
|
}
|
|
256
267
|
}
|
|
257
268
|
],
|
|
@@ -261,8 +272,8 @@
|
|
|
261
272
|
"line": 1
|
|
262
273
|
},
|
|
263
274
|
{
|
|
264
|
-
"name": "@
|
|
265
|
-
"line":
|
|
275
|
+
"name": "@get",
|
|
276
|
+
"line": 28
|
|
266
277
|
}
|
|
267
278
|
],
|
|
268
279
|
"type": "scenario"
|
package/scripts/linkReports.js
CHANGED
|
@@ -1,122 +1,69 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
|
-
const { minify } = require("html-minifier-terser");
|
|
4
3
|
|
|
5
4
|
const reportsDir = path.resolve("reports");
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Finds the first file that looks like a Cucumber HTML report.
|
|
8
|
+
*/
|
|
9
|
+
function findCucumberReportFile() {
|
|
8
10
|
const files = fs.readdirSync(reportsDir);
|
|
9
11
|
return files.find((f) => f.includes("cucumber") && f.endsWith(".html"));
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const match = withoutScripts.match(/<body[^>]*>([\s\S]*)<\/body>/i);
|
|
19
|
-
return match
|
|
20
|
-
? match[1]
|
|
21
|
-
: "<p>⚠️ Failed to extract body of Cucumber report.</p>";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function extractK6ReportBody(file) {
|
|
25
|
-
const html = fs.readFileSync(file, "utf-8");
|
|
26
|
-
const match = html.match(/<body[^>]*>([\s\S]*)<\/body>/i);
|
|
27
|
-
return match ? match[1] : "";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function buildCombinedHtml({ title, k6Bodies, cucumberBody }) {
|
|
31
|
-
const tabs = k6Bodies
|
|
32
|
-
.map(
|
|
33
|
-
(_, i) => `
|
|
34
|
-
<input type="radio" name="tabs" id="tabk6${i}" ${i === 0 ? "checked" : ""}>
|
|
35
|
-
<label for="tabk6${i}">K6 Report ${i + 1}</label>
|
|
36
|
-
<div class="tab">
|
|
37
|
-
${k6Bodies[i]}
|
|
38
|
-
</div>
|
|
39
|
-
`
|
|
40
|
-
)
|
|
41
|
-
.join("\n");
|
|
14
|
+
/**
|
|
15
|
+
* Adds a Cucumber report tab as an iframe.
|
|
16
|
+
*/
|
|
17
|
+
function addLinksToReport(targetFile, cucumberFileName) {
|
|
18
|
+
const content = fs.readFileSync(targetFile, "utf-8");
|
|
42
19
|
|
|
43
20
|
const cucumberTab = `
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
21
|
+
<input type="radio" name="tabs" id="tabcucumber">
|
|
22
|
+
<label for="tabcucumber"><i class="fas fa-file-alt"></i> Cucumber Report</label>
|
|
23
|
+
<div class="tab">
|
|
24
|
+
${
|
|
25
|
+
cucumberFileName
|
|
26
|
+
? `<iframe src="${cucumberFileName}" style="width:100%; min-height:600px; border:none;"></iframe>`
|
|
27
|
+
: `<p style="color:red; padding:1rem;">⚠️ Cucumber HTML report not found in <code>reports/</code> directory.</p>`
|
|
28
|
+
}
|
|
29
|
+
</div>
|
|
51
30
|
`;
|
|
52
31
|
|
|
53
|
-
const
|
|
32
|
+
const modifiedContent = content
|
|
33
|
+
.replace(
|
|
34
|
+
/<input type="radio" name="tabs" id="tabone"/,
|
|
35
|
+
`${cucumberTab}\n<input type="radio" name="tabs" id="tabone"`
|
|
36
|
+
)
|
|
37
|
+
.replace(/<div style="[^>]*margin-top:20px;[^>]*">[\s\S]*?<\/div>/g, "");
|
|
54
38
|
|
|
55
|
-
|
|
56
|
-
<!DOCTYPE html>
|
|
57
|
-
<html lang="en">
|
|
58
|
-
<head>
|
|
59
|
-
<meta charset="UTF-8" />
|
|
60
|
-
<title>${title}</title>
|
|
61
|
-
<link rel="stylesheet" href="https://unpkg.com/purecss@2.0.3/build/pure-min.css" crossorigin="anonymous">
|
|
62
|
-
<style>
|
|
63
|
-
body { margin:1rem; font-family:sans-serif; }
|
|
64
|
-
.tabs { display:flex; flex-wrap:wrap; }
|
|
65
|
-
.tabs label { order:1; padding:1rem; cursor:pointer; background:#ddd; margin-right:0.2rem; border-radius:5px 5px 0 0; }
|
|
66
|
-
.tabs .tab { order:99; flex-grow:1; width:100%; display:none; padding:1rem; background:#fff; }
|
|
67
|
-
.tabs input[type="radio"] { display:none; }
|
|
68
|
-
.tabs input[type="radio"]:checked + label { background:#fff; font-weight:bold; }
|
|
69
|
-
.tabs input[type="radio"]:checked + label + .tab { display:block; }
|
|
70
|
-
</style>
|
|
71
|
-
</head>
|
|
72
|
-
<body>
|
|
73
|
-
<h1>${title}</h1>
|
|
74
|
-
<div class="tabs">
|
|
75
|
-
${fullTabs}
|
|
76
|
-
</div>
|
|
77
|
-
</body>
|
|
78
|
-
</html>`;
|
|
39
|
+
fs.writeFileSync(targetFile, modifiedContent, "utf-8");
|
|
79
40
|
}
|
|
80
41
|
|
|
81
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Adds a Cucumber tab to every K6 HTML report found in /reports.
|
|
44
|
+
*/
|
|
45
|
+
function linkReports() {
|
|
82
46
|
if (!fs.existsSync(reportsDir)) {
|
|
83
47
|
console.warn("⚠️ No reports directory found.");
|
|
84
48
|
return;
|
|
85
49
|
}
|
|
86
50
|
|
|
87
|
-
const cucumberFile =
|
|
88
|
-
const cucumberBody = cucumberFile
|
|
89
|
-
? extractCucumberBody(path.join(reportsDir, cucumberFile))
|
|
90
|
-
: null;
|
|
51
|
+
const cucumberFile = findCucumberReportFile();
|
|
91
52
|
|
|
92
|
-
const
|
|
53
|
+
const htmlFiles = fs
|
|
93
54
|
.readdirSync(reportsDir)
|
|
94
55
|
.filter((f) => /^k6-report.*\.html$/.test(f));
|
|
95
|
-
|
|
96
|
-
|
|
56
|
+
|
|
57
|
+
if (htmlFiles.length === 0) {
|
|
58
|
+
console.warn("⚠️ No K6 reports found to inject.");
|
|
97
59
|
return;
|
|
98
60
|
}
|
|
99
61
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const combinedHtml = buildCombinedHtml({
|
|
105
|
-
title: "Combined K6 + Cucumber Report",
|
|
106
|
-
k6Bodies,
|
|
107
|
-
cucumberBody,
|
|
62
|
+
htmlFiles.forEach((file) => {
|
|
63
|
+
const fullPath = path.join(reportsDir, file);
|
|
64
|
+
addLinksToReport(fullPath, cucumberFile);
|
|
65
|
+
console.log(`🔗 Injected Cucumber tab into: ${file}`);
|
|
108
66
|
});
|
|
109
|
-
|
|
110
|
-
const finalHtml = await minify(combinedHtml, {
|
|
111
|
-
collapseWhitespace: true,
|
|
112
|
-
removeComments: true,
|
|
113
|
-
minifyCSS: true,
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const outPath = path.join(reportsDir, "combined-report.html");
|
|
117
|
-
fs.writeFileSync(outPath, finalHtml, "utf-8");
|
|
118
|
-
|
|
119
|
-
console.log(`✅ Combined and minified report saved to: ${outPath}`);
|
|
120
67
|
}
|
|
121
68
|
|
|
122
69
|
module.exports = { linkReports };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
import http from 'k6/http';
|
|
3
|
+
import { check } from 'k6';
|
|
4
|
+
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
|
|
5
|
+
import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.1/index.js";
|
|
6
|
+
|
|
7
|
+
export const options = {
|
|
8
|
+
"vus": 10,
|
|
9
|
+
"duration": "5s",
|
|
10
|
+
"thresholds": {
|
|
11
|
+
"http_req_failed": [
|
|
12
|
+
"rate<0.05"
|
|
13
|
+
],
|
|
14
|
+
"http_req_duration": [
|
|
15
|
+
"p(95)<5000"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default function () {
|
|
21
|
+
const headers = {
|
|
22
|
+
"Content-Type": "application/json"
|
|
23
|
+
};
|
|
24
|
+
const body = undefined;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const resolvedUrl0 = "https://sandbox-decide-api.indicina.net/get?foo1=bar1&foo2=bar2";
|
|
28
|
+
const res0 = http.request("GET", resolvedUrl0, null, { headers });
|
|
29
|
+
console.log(`Response Body for ${resolvedUrl0}: ${res0.body}`);
|
|
30
|
+
check(res0, {
|
|
31
|
+
"status is 2xx": (r) => r.status >= 200 && r.status < 300
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const resolvedUrl1 = "https://postman-echo.com/get?foo1=bar1&foo2=bar2";
|
|
36
|
+
const res1 = http.request("GET", resolvedUrl1, null, { headers });
|
|
37
|
+
console.log(`Response Body for ${resolvedUrl1}: ${res1.body}`);
|
|
38
|
+
check(res1, {
|
|
39
|
+
"status is 2xx": (r) => r.status >= 200 && r.status < 300
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function handleSummary(data) {
|
|
45
|
+
const outputDir = __ENV.REPORT_OUTPUT_DIR || "reports";
|
|
46
|
+
const html = htmlReport(data);
|
|
47
|
+
const cucumberReportFile = "cucumber-report.html";
|
|
48
|
+
const cucumberLink = `
|
|
49
|
+
<div style="text-align:center; margin-top:20px;">
|
|
50
|
+
<a href="${cucumberReportFile}" style="font-size:18px; color:#0066cc;">
|
|
51
|
+
🔗 View Cucumber Test Report
|
|
52
|
+
</a>
|
|
53
|
+
</div>
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
57
|
+
const k6ReportFilename = `${outputDir}/k6-report-${timestamp}.html`;
|
|
58
|
+
|
|
59
|
+
console.log(`📄 K6 HTML report ${k6ReportFilename} generated successfully 👍`);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
[k6ReportFilename]: html.replace("</body>", `${cucumberLink}</body>`),
|
|
63
|
+
stdout: textSummary(data, { indent: " ", enableColors: true }),
|
|
64
|
+
};
|
|
65
|
+
}
|