k6-cucumber-steps 1.0.37 → 1.0.39

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
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -66,6 +66,7 @@
66
66
  "@babel/register": "latest",
67
67
  "@cucumber/cucumber": "latest",
68
68
  "@faker-js/faker": "latest",
69
+ "axios": "^1.9.0",
69
70
  "dotenv": "latest",
70
71
  "yargs": "latest"
71
72
  }
@@ -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
@@ -227,10 +231,12 @@ Then(
227
231
  When(
228
232
  "I login via POST to {string} with payload from {string}",
229
233
  async function (endpoint, fileName) {
230
- const payloadPath = path.resolve(__dirname, "../../payloads", fileName);
234
+ const basePayloadPath =
235
+ this.parameters?.payloadPath || path.resolve(__dirname, "../../payloads");
236
+ const payloadPath = path.resolve(basePayloadPath, fileName);
231
237
 
232
238
  if (!fs.existsSync(payloadPath)) {
233
- throw new Error(`Payload file not found: ${fileName}`);
239
+ throw new Error(`Payload file not found: ${payloadPath}`);
234
240
  }
235
241
 
236
242
  const rawTemplate = fs.readFileSync(payloadPath, "utf-8");