k6-cucumber-steps 1.0.19 → 1.0.21

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/.env CHANGED
@@ -13,5 +13,5 @@ TAGS=@loadTest
13
13
  BASE_URL=https://postman-echo.com
14
14
 
15
15
  # Secret Parameters
16
- API_KEY=Talent123!
17
- BEARER_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3J1bnRocm91Z2gtdHdvLnNlYW1sZXNzaHJtcy5jb20vYXBpL3YxL2F1dGgvbG9naW4iLCJpYXQiOjE3NDU2MjAwNDEsImV4cCI6MTc0NTYyMzY0MSwibmJmIjoxNzQ1NjIwMDQxLCJqdGkiOiJkQmZHZW9Takh3MlZ0NEF6Iiwic3ViIjoiMjI2IiwicHJ2IjoiYzIwM2QyYmJmODZhN2IyNzcyZWUyNGNhODIyNzBmOTA5NTgyZjg3YyJ9.WGdq8QMpSZvCJB6cj0hn3xrUIfhIbOE4Ft4bo8u1JKw
16
+ API_KEY=Ta344
17
+ BEARER_TOKEN=efhIbOE4Ft4bo8u1JKw
@@ -43,8 +43,7 @@ const cucumberArgs = [
43
43
  "progress", // Add this line
44
44
  ];
45
45
 
46
- // Explicitly add tags, defaulting to '@loadTest' if no TAGS env variable is set
47
- const tagsFromEnv = process.env.TAGS || "@loadTest";
46
+ const tagsFromEnv = process.env.TAGS || " ";
48
47
  cucumberArgs.push("--tags", tagsFromEnv);
49
48
 
50
49
  if (argv.feature) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,7 +40,7 @@ body{padding:0;margin:0}.html-formatter{max-width:1600px;min-height:100vh;margin
40
40
  <div id="content">
41
41
  </div>
42
42
  <script>
43
- window.CUCUMBER_MESSAGES = [{"meta":{"protocolVersion":"27.0.2","implementation":{"version":"11.2.0","name":"cucumber-js"},"cpu":{"name":"arm64"},"os":{"name":"darwin","version":"24.3.0"},"runtime":{"name":"node.js","version":"22.14.0"}}},{"stepDefinition":{"id":"10328197-b350-4484-b9e5-9b3d47e5b427","pattern":{"source":"I set a k6 script for {word} testing","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"node_modules\/k6-cucumber-steps\/step_definitions\/load_test_steps.js","location":{"line":21}}}},{"stepDefinition":{"id":"a9d5a660-950c-447c-83ce-2240c4958189","pattern":{"source":"I set to run the k6 script with the following configurations:","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"node_modules\/k6-cucumber-steps\/step_definitions\/load_test_steps.js","location":{"line":25}}}},{"stepDefinition":{"id":"6d8c50bc-af04-4cd3-b1bf-454a4e3dddb0","pattern":{"source":"I set the request headers:","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"node_modules\/k6-cucumber-steps\/step_definitions\/load_test_steps.js","location":{"line":71}}}},{"stepDefinition":{"id":"79768ea2-d2c9-470f-a373-2bfdd7696653","pattern":{"source":"I set the following endpoint\\(s) used:","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"node_modules\/k6-cucumber-steps\/step_definitions\/load_test_steps.js","location":{"line":83}}}},{"stepDefinition":{"id":"aba9ee98-d587-4041-abc6-189176191d83","pattern":{"source":"I set the following {word} body is used for {string}","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"node_modules\/k6-cucumber-steps\/step_definitions\/load_test_steps.js","location":{"line":90}}}},{"stepDefinition":{"id":"1279e95a-e52e-4de7-bbd2-fc05c4ca74b5","pattern":{"source":"I set the authentication type is {string}","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"node_modules\/k6-cucumber-steps\/step_definitions\/load_test_steps.js","location":{"line":99}}}},{"stepDefinition":{"id":"4c447da6-eec3-4146-a68c-25fd474c2212","pattern":{"source":"I see the API should handle the {word} request successfully","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"node_modules\/k6-cucumber-steps\/step_definitions\/load_test_steps.js","location":{"line":103}}}},{"stepDefinition":{"id":"db10c2d5-10dd-4301-bfc2-f1bf8af6c95d","pattern":{"source":"I set a k6 script for {word} testing","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":21}}}},{"stepDefinition":{"id":"f931de79-26c9-4556-8ebf-16d43b45ca47","pattern":{"source":"I set to run the k6 script with the following configurations:","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":25}}}},{"stepDefinition":{"id":"0db39943-3f2b-4737-9919-0a4a2e425c32","pattern":{"source":"I set the request headers:","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":71}}}},{"stepDefinition":{"id":"6f4951d9-9744-42e7-b6a0-651d3fce75de","pattern":{"source":"I set the following endpoint\\(s) used:","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":83}}}},{"stepDefinition":{"id":"e71e973b-c2b4-42d2-a191-35eefaabcbc2","pattern":{"source":"I set the following {word} body is used for {string}","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":90}}}},{"stepDefinition":{"id":"130868e1-6dda-4720-9e93-5575a5e33c88","pattern":{"source":"I set the authentication type is {string}","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":99}}}},{"stepDefinition":{"id":"85f3755e-aebe-4a85-9535-0b75b5547c6e","pattern":{"source":"I see the API should handle the {word} request successfully","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":103}}}},{"testRunStarted":{"id":"b3662237-3028-4a8b-b30e-47364453f749","timestamp":{"seconds":1745791966,"nanos":315000000}}},{"testRunFinished":{"testRunStartedId":"b3662237-3028-4a8b-b30e-47364453f749","timestamp":{"seconds":1745791966,"nanos":315000000},"success":true}}];
43
+ window.CUCUMBER_MESSAGES = [{"meta":{"protocolVersion":"27.0.2","implementation":{"version":"11.2.0","name":"cucumber-js"},"cpu":{"name":"arm64"},"os":{"name":"darwin","version":"24.3.0"},"runtime":{"name":"node.js","version":"22.14.0"}}},{"stepDefinition":{"id":"f27054a5-fe78-484b-a714-342e0b67aece","pattern":{"source":"I set a k6 script for {word} testing","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":21}}}},{"stepDefinition":{"id":"4da80a21-ad67-40cc-9558-a541a75c6405","pattern":{"source":"I set to run the k6 script with the following configurations:","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":25}}}},{"stepDefinition":{"id":"da5c035a-a857-4eaf-8795-7d12ef330787","pattern":{"source":"I set the request headers:","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":71}}}},{"stepDefinition":{"id":"8e5b884f-e1fa-4fda-b628-2f653f465d42","pattern":{"source":"I set the following endpoint\\(s) used:","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":83}}}},{"stepDefinition":{"id":"2c465282-7ba0-4c86-960f-783e55e77e98","pattern":{"source":"I set the following {word} body is used for {string}","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":90}}}},{"stepDefinition":{"id":"e87fc015-7de7-432a-b8c2-cfa93d98aa69","pattern":{"source":"I set the authentication type is {string}","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":99}}}},{"stepDefinition":{"id":"f58e290e-a8b1-4992-8278-662efa27882b","pattern":{"source":"I see the API should handle the {word} request successfully","type":"CUCUMBER_EXPRESSION"},"sourceReference":{"uri":"step_definitions\/load_test_steps.js","location":{"line":103}}}},{"testRunStarted":{"id":"a14f0eb5-e1e1-4196-8b5b-665bdea98eb1","timestamp":{"seconds":1745793198,"nanos":679000000}}},{"testRunFinished":{"testRunStartedId":"a14f0eb5-e1e1-4196-8b5b-665bdea98eb1","timestamp":{"seconds":1745793198,"nanos":680000000},"success":true}}];
44
44
  </script>
45
45
  <script>
46
46
  /*! For license information please see main.js.LICENSE.txt */
@@ -57,7 +57,7 @@ declare function When(
57
57
  ) => void
58
58
  ): void;
59
59
  declare function When(
60
- pattern: "I set the following endpoint\\(s) used:",
60
+ pattern: "I set the following endpoints used:",
61
61
  implementation: (
62
62
  this: import("@cucumber/cucumber").World,
63
63
  docString: string
@@ -73,7 +73,7 @@ declare function When(
73
73
  ) => void
74
74
  ): void;
75
75
  declare function When(
76
- pattern: "I set the authentication type is {string}",
76
+ pattern: "I set the authentication type to {string}",
77
77
  implementation: (
78
78
  this: import("@cucumber/cucumber").World,
79
79
  authType: string
@@ -18,10 +18,24 @@ const validateThreshold = (threshold) => {
18
18
  }
19
19
  };
20
20
 
21
+ /**
22
+ * @param {string} method - HTTP method (e.g., GET, POST).
23
+ * @example
24
+ * Given I set a k6 script for GET testing
25
+ * Given I set a k6 script for POST testing
26
+ */
21
27
  Given("I set a k6 script for {word} testing", function (method) {
22
28
  this.config = { method: method.toUpperCase() };
23
29
  });
24
30
 
31
+ /**
32
+ * @param {DataTable} dataTable - Table with configurations.
33
+ * @example
34
+ * When I set to run the k6 script with the following configurations:
35
+ * | virtual_users | duration | http_req_failed | http_req_duration | error_rate | stages |
36
+ * | 10 | 5 | rate<0.05 | p(95)<200 | | |
37
+ * | 50 | 10 | | | rate<0.01 | [{"target": 10, "duration": "10s"}, {"target": 50, "duration": "30s"}] |
38
+ */
25
39
  When(
26
40
  "I set to run the k6 script with the following configurations:",
27
41
  function (dataTable) {
@@ -68,6 +82,15 @@ When(
68
82
  }
69
83
  }
70
84
  );
85
+
86
+ /**
87
+ * @param {DataTable} dataTable - Table with header and value for request headers.
88
+ * @example
89
+ * When I set the request headers:
90
+ * | Header | Value |
91
+ * | Content-Type | application/json |
92
+ * | Authorization | Bearer your_auth_token |
93
+ */
71
94
  When("I set the request headers:", function (dataTable) {
72
95
  const headers = {};
73
96
  dataTable.hashes().forEach(({ Header, Value }) => {
@@ -80,13 +103,35 @@ When("I set the request headers:", function (dataTable) {
80
103
  };
81
104
  });
82
105
 
83
- When("I set the following endpoint\\(s) used:", function (docString) {
106
+ /**
107
+ * @param {string} docString - Multiline string containing the endpoints.
108
+ * @example
109
+ * When I set the following endpoints used:
110
+ * """
111
+ * /api/users
112
+ * /api/products
113
+ * """
114
+ */
115
+ When("I set the following endpoints used:", function (docString) {
84
116
  this.config.endpoints = docString
85
117
  .trim()
86
118
  .split("\n")
87
119
  .map((line) => line.trim());
88
120
  });
89
121
 
122
+ /**
123
+ * @param {string} method - HTTP method (e.g., POST, PUT).
124
+ * @param {string} endpoint - The endpoint for the body.
125
+ * @param {string} docString - Multiline string containing the request body (can use placeholders).
126
+ * @example
127
+ * When I set the following POST body is used for "/api/users"
128
+ * """
129
+ * {
130
+ * "username": "{{username}}",
131
+ * "email": "{{faker.internet.email}}"
132
+ * }
133
+ * """
134
+ */
90
135
  When(
91
136
  "I set the following {word} body is used for {string}",
92
137
  function (method, endpoint, docString) {
@@ -96,10 +141,24 @@ When(
96
141
  }
97
142
  );
98
143
 
99
- When("I set the authentication type is {string}", function (authType) {
144
+ /**
145
+ * @param {string} authType - Authentication type (api_key, bearer_token, basic, none).
146
+ * @example
147
+ * When I set the authentication type to "bearer_token"
148
+ * When I set the authentication type to "api_key"
149
+ * When I set the authentication type to "basic"
150
+ * When I set the authentication type to "none"
151
+ */
152
+ When("I set the authentication type to {string}", function (authType) {
100
153
  this.config.headers = generateHeaders(authType, process.env);
101
154
  });
102
155
 
156
+ /**
157
+ * @param {string} method - HTTP method of the request.
158
+ * @example
159
+ * Then I see the API should handle the GET request successfully
160
+ * Then I see the API should handle the POST request successfully
161
+ */
103
162
  Then(
104
163
  "I see the API should handle the {word} request successfully",
105
164
  { timeout: 60000 },