k6-cucumber-steps 2.0.9 → 2.0.10

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
@@ -179,6 +179,30 @@ npx k6-cucumber-steps generate -f ./features
179
179
 
180
180
  **Excluded directories:** `node_modules/`, hidden directories (`.git/`, `.github/`, etc.)
181
181
 
182
+ ### 🗑️ DELETE Request Support (NEW!)
183
+
184
+ Full DELETE request support with environment variables and alias replacement:
185
+
186
+ ```gherkin
187
+ # Basic DELETE
188
+ When I k6 make a DELETE request to "/users/1"
189
+
190
+ # DELETE with env vars
191
+ When I k6 make a DELETE request to "/users/{{USER_ID}}"
192
+
193
+ # DELETE with custom headers
194
+ When I k6 make a DELETE request to "/api/items/1" with headers:
195
+ | Authorization |
196
+ | Bearer {{authToken}} |
197
+
198
+ # DELETE with payload file
199
+ When I k6 make a DELETE request to "/api/bulk" with payload from "data/delete-payload.json"
200
+ ```
201
+
202
+ **Supports:**
203
+ - `{{VARIABLE_NAME}}` for environment variables
204
+ - `{{alias:NAME}}` for stored aliases in payload files
205
+
182
206
  ### 📁 Multiple Feature Paths
183
207
 
184
208
  Specify **multiple directories or files** using comma-separated paths.
@@ -591,6 +615,7 @@ When I k6 make a GET request to "/users/1" with headers:
591
615
 
592
616
  # POST requests
593
617
  When I k6 make a POST request to "/users"
618
+ When I k6 make a POST request to "/users" with payload from "payload.json"
594
619
 
595
620
  # PUT requests
596
621
  When I k6 make a PUT request to "/users/1"
@@ -599,6 +624,13 @@ When I k6 make a PUT request to "/users/1" with body:
599
624
  # PATCH requests
600
625
  When I k6 make a PATCH request to "/settings"
601
626
  When I k6 make a PATCH request to "/settings" with body:
627
+
628
+ # DELETE requests (NEW!)
629
+ When I k6 make a DELETE request to "/users/1"
630
+ When I k6 make a DELETE request to "/users/{{USER_ID}}" with headers:
631
+ | Authorization |
632
+ | Bearer {{authToken}} |
633
+ When I k6 make a DELETE request to "/api/items/1" with payload from "data/delete-payload.json"
602
634
  ```
603
635
 
604
636
  ### Sample Features
@@ -1 +1 @@
1
- {"version":3,"file":"sample-steps.generator.d.ts","sourceRoot":"","sources":["../../../src/generators/samples/sample-steps.generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,qBAAa,oBAAoB;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IAgBzD,OAAO,CAAC,uBAAuB;CAwoChC"}
1
+ {"version":3,"file":"sample-steps.generator.d.ts","sourceRoot":"","sources":["../../../src/generators/samples/sample-steps.generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,qBAAa,oBAAoB;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IAgBzD,OAAO,CAAC,uBAAuB;CAssChC"}
@@ -526,6 +526,68 @@ export function k6IMakeAPatchRequestToWithBody(endpoint: string, bodyData: any)
526
526
  globalThis.lastResponse = response;
527
527
  }
528
528
 
529
+ /**
530
+ * Makes a DELETE request to the specified endpoint.
531
+ * Supports {{VARIABLE_NAME}} for env vars in endpoint.
532
+ */
533
+ export function k6IMakeADeleteRequestTo(endpoint: string) {
534
+ const resolvedEndpoint = replaceEnvVariables(endpoint);
535
+ const url = \`\${baseUrl}\${resolvedEndpoint}\`;
536
+ const response = http.del(url, null, { headers: defaultHeaders });
537
+ globalThis.lastResponse = response;
538
+ }
539
+
540
+ /**
541
+ * Makes a DELETE request with custom headers.
542
+ * Supports {{VARIABLE_NAME}} for env vars in endpoint.
543
+ */
544
+ export function k6IMakeADeleteRequestToWithHeaders(endpoint: string, headersTable: any) {
545
+ const resolvedEndpoint = replaceEnvVariables(endpoint);
546
+ const url = \`\${baseUrl}\${resolvedEndpoint}\`;
547
+ let requestHeaders = { ...defaultHeaders };
548
+ if (headersTable?.length > 0) {
549
+ Object.assign(requestHeaders, headersTable[0]);
550
+ }
551
+ const response = http.del(url, null, { headers: requestHeaders });
552
+ globalThis.lastResponse = response;
553
+ }
554
+
555
+ /**
556
+ * Makes a DELETE request using a payload.json file.
557
+ * Supports {{VARIABLE_NAME}} for env vars and {{alias:NAME}} for stored aliases.
558
+ */
559
+ export function k6IMakeADeleteRequestToWithPayloadFile(endpoint: string, fileName: string) {
560
+ const fs = require('fs');
561
+ const path = require('path');
562
+
563
+ // Resolve payload file path
564
+ let filePath = fileName;
565
+ if (!path.isAbsolute(fileName)) {
566
+ if (fs.existsSync(path.join(process.cwd(), 'data', fileName))) {
567
+ filePath = path.join(process.cwd(), 'data', fileName);
568
+ } else if (fs.existsSync(path.join(process.cwd(), fileName))) {
569
+ filePath = path.join(process.cwd(), fileName);
570
+ } else {
571
+ filePath = path.join(process.cwd(), 'payload.json');
572
+ }
573
+ }
574
+
575
+ if (!fs.existsSync(filePath)) {
576
+ console.error(\`❌ Payload file not found: \${filePath}\`);
577
+ return;
578
+ }
579
+
580
+ let payloadContent = fs.readFileSync(filePath, 'utf8');
581
+ payloadContent = replaceEnvVariables(payloadContent);
582
+ payloadContent = replaceAliasVariables(payloadContent);
583
+
584
+ const resolvedEndpoint = replaceEnvVariables(endpoint);
585
+ const url = \`\${baseUrl}\${resolvedEndpoint}\`;
586
+ const response = http.del(url, payloadContent, { headers: defaultHeaders });
587
+ globalThis.lastResponse = response;
588
+ console.log(\`🗑️ DELETE \${url} with payload from \${filePath}\`);
589
+ }
590
+
529
591
  export function k6TheResponsePropertyShouldBe(propertyPath: string, expectedValue: string) {
530
592
  const res = globalThis.lastResponse;
531
593
  if (!res) {
@@ -1 +1 @@
1
- {"version":3,"file":"sample-steps.generator.js","sourceRoot":"","sources":["../../../src/generators/samples/sample-steps.generator.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAmD;AACnD,4CAAoB;AACpB,gDAAwB;AAExB,yEAAoE;AAEpE,MAAa,oBAAoB;IAC/B,QA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmsCV,CAAC;IACA,CAAC;CACF;AAvtCD,oDAutCC"}
@@ -178,6 +178,35 @@
178
178
  "fileName: string"
179
179
  ]
180
180
  },
181
+ {
182
+ "step": "I k6 make a DELETE request to {string}",
183
+ "functionName": "k6IMakeADeleteRequestTo",
184
+ "description": "Makes a DELETE request to the specified endpoint (supports {{VARIABLE_NAME}})",
185
+ "category": "HTTP",
186
+ "parameters": [
187
+ "endpoint: string"
188
+ ]
189
+ },
190
+ {
191
+ "step": "I k6 make a DELETE request to {string} with headers:",
192
+ "functionName": "k6IMakeADeleteRequestToWithHeaders",
193
+ "description": "Makes a DELETE request with custom headers (supports {{VARIABLE_NAME}})",
194
+ "category": "HTTP",
195
+ "parameters": [
196
+ "endpoint: string",
197
+ "headersTable: any"
198
+ ]
199
+ },
200
+ {
201
+ "step": "I k6 make a DELETE request to {string} with payload from {string}",
202
+ "functionName": "k6IMakeADeleteRequestToWithPayloadFile",
203
+ "description": "Makes a DELETE request using a payload.json file (supports {{VARIABLE_NAME}} and {{alias:NAME}})",
204
+ "category": "HTTP",
205
+ "parameters": [
206
+ "endpoint: string",
207
+ "fileName: string"
208
+ ]
209
+ },
181
210
  {
182
211
  "step": "the k6 response status should be {string}",
183
212
  "functionName": "k6TheResponseStatusShouldBe",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "description": "Generate k6 test scripts from Cucumber feature files",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {