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 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
@@ -8,6 +8,9 @@ module.exports = {
8
8
  ],
9
9
  paths: ["./src/examples/features/loadTestTemplate.feature"],
10
10
  tags: process.env.TAGS,
11
+ worldParameters: {
12
+ payloadPath: "apps/qa/performance/payloads",
13
+ },
11
14
  overwrite: true,
12
15
  reporter: true,
13
16
  },
@@ -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
- // Do nothing extra
24
+ // No auth, just default content-type
25
25
  } else if (aliases[authType]) {
26
- // Dynamic alias token support
26
+ // Custom alias support
27
27
  headers["Authorization"] = `Bearer ${getValue(authType)}`;
28
28
  } else {
29
29
  throw new Error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -156,9 +156,12 @@ When(
156
156
  );
157
157
  }
158
158
 
159
- const payloadPath = path.resolve(__dirname, "../../payloads", fileName);
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: ${fileName}`);
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(authType, process.env);
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 payloadPath = path.resolve(__dirname, "../../payloads", fileName);
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: ${fileName}`);
244
+ throw new Error(`Payload file not found: ${payloadPath}`);
234
245
  }
235
246
 
236
247
  const rawTemplate = fs.readFileSync(payloadPath, "utf-8");