k6-cucumber-steps 1.0.38 → 1.0.40
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/README.md +3 -0
- package/cucumber.js +3 -0
- package/lib/helpers/generateHeaders.js +2 -2
- package/package.json +1 -1
- package/step_definitions/load_test_steps.js +16 -5
package/README.md
CHANGED
|
@@ -124,6 +124,9 @@ Here's a step-by-step guide to using `k6-cucumber-steps` in your project:
|
|
|
124
124
|
],
|
|
125
125
|
paths: ["./features/*.feature"],
|
|
126
126
|
tags: process.env.TAGS,
|
|
127
|
+
worldParameters: {
|
|
128
|
+
payloadPath: "apps/qa/performance/payloads"
|
|
129
|
+
}
|
|
127
130
|
overwrite: false, // Default to not overwrite the report file
|
|
128
131
|
};
|
|
129
132
|
```
|
package/cucumber.js
CHANGED
|
@@ -21,9 +21,9 @@ module.exports = function generateHeaders(authType, env, aliases = {}) {
|
|
|
21
21
|
).toString("base64");
|
|
22
22
|
headers["Authorization"] = `Basic ${base64}`;
|
|
23
23
|
} else if (authType === "none") {
|
|
24
|
-
//
|
|
24
|
+
// No auth, just default content-type
|
|
25
25
|
} else if (aliases[authType]) {
|
|
26
|
-
//
|
|
26
|
+
// ✅ Custom alias support
|
|
27
27
|
headers["Authorization"] = `Bearer ${getValue(authType)}`;
|
|
28
28
|
} else {
|
|
29
29
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -156,9 +156,12 @@ When(
|
|
|
156
156
|
);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
const
|
|
159
|
+
const basePayloadPath =
|
|
160
|
+
this.parameters?.payloadPath || path.resolve(__dirname, "../../payloads");
|
|
161
|
+
const payloadPath = path.resolve(basePayloadPath, fileName);
|
|
162
|
+
|
|
160
163
|
if (!fs.existsSync(payloadPath)) {
|
|
161
|
-
throw new Error(`Payload file not found: ${
|
|
164
|
+
throw new Error(`Payload file not found: ${payloadPath}`);
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
const rawTemplate = fs.readFileSync(payloadPath, "utf-8");
|
|
@@ -185,6 +188,7 @@ When(
|
|
|
185
188
|
};
|
|
186
189
|
}
|
|
187
190
|
);
|
|
191
|
+
|
|
188
192
|
/**
|
|
189
193
|
* @param {string} authType - Authentication type (api_key, bearer_token, basic, none).
|
|
190
194
|
* @example
|
|
@@ -194,8 +198,13 @@ When(
|
|
|
194
198
|
* When I set the authentication type to "none"
|
|
195
199
|
*/
|
|
196
200
|
When("I set the authentication type to {string}", function (authType) {
|
|
197
|
-
this.config.headers = generateHeaders(
|
|
201
|
+
this.config.headers = generateHeaders(
|
|
202
|
+
authType,
|
|
203
|
+
process.env,
|
|
204
|
+
this.aliases || {}
|
|
205
|
+
);
|
|
198
206
|
});
|
|
207
|
+
|
|
199
208
|
/**
|
|
200
209
|
* Then I store the value at "data.token" as alias "token"
|
|
201
210
|
*/
|
|
@@ -227,10 +236,12 @@ Then(
|
|
|
227
236
|
When(
|
|
228
237
|
"I login via POST to {string} with payload from {string}",
|
|
229
238
|
async function (endpoint, fileName) {
|
|
230
|
-
const
|
|
239
|
+
const basePayloadPath =
|
|
240
|
+
this.parameters?.payloadPath || path.resolve(__dirname, "../../payloads");
|
|
241
|
+
const payloadPath = path.resolve(basePayloadPath, fileName);
|
|
231
242
|
|
|
232
243
|
if (!fs.existsSync(payloadPath)) {
|
|
233
|
-
throw new Error(`Payload file not found: ${
|
|
244
|
+
throw new Error(`Payload file not found: ${payloadPath}`);
|
|
234
245
|
}
|
|
235
246
|
|
|
236
247
|
const rawTemplate = fs.readFileSync(payloadPath, "utf-8");
|