k6-cucumber-steps 1.0.19 → 1.0.20
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/package.json
CHANGED
|
@@ -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":"
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 },
|