k6-cucumber-steps 1.1.10 → 1.1.11
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.
|
@@ -18,8 +18,14 @@ module.exports = function buildK6Script(config) {
|
|
|
18
18
|
return url.startsWith("/") ? `${BASE_URL}${url}` : url;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const
|
|
21
|
+
// Default headers/body/options for safety
|
|
22
|
+
const safeHeaders = headers && Object.keys(headers).length ? headers : {};
|
|
23
|
+
const safeBody = body !== undefined ? body : null;
|
|
24
|
+
const safeOptions = options && Object.keys(options).length ? options : {};
|
|
25
|
+
|
|
26
|
+
// Stringify for script
|
|
27
|
+
const stringifiedHeaders = JSON.stringify(safeHeaders, null, 2);
|
|
28
|
+
const stringifiedBody = JSON.stringify(safeBody, null, 2);
|
|
23
29
|
|
|
24
30
|
return `
|
|
25
31
|
import http from 'k6/http';
|
|
@@ -27,7 +33,7 @@ import { check } from 'k6';
|
|
|
27
33
|
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
|
|
28
34
|
import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.1/index.js";
|
|
29
35
|
|
|
30
|
-
export const options = ${JSON.stringify(
|
|
36
|
+
export const options = ${JSON.stringify(safeOptions, null, 2)};
|
|
31
37
|
|
|
32
38
|
export default function () {
|
|
33
39
|
const headers = ${stringifiedHeaders};
|