k6-cucumber-steps 1.2.27 → 2.0.1
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 +190 -177
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +72 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init.command.d.ts +4 -0
- package/dist/commands/init.command.d.ts.map +1 -0
- package/dist/commands/init.command.js +30 -0
- package/dist/commands/init.command.js.map +1 -0
- package/dist/generators/feature.parser.d.ts +12 -0
- package/dist/generators/feature.parser.d.ts.map +1 -0
- package/dist/generators/feature.parser.js +208 -0
- package/dist/generators/feature.parser.js.map +1 -0
- package/dist/generators/k6-script.generator.d.ts +11 -0
- package/dist/generators/k6-script.generator.d.ts.map +1 -0
- package/dist/generators/k6-script.generator.js +233 -0
- package/dist/generators/k6-script.generator.js.map +1 -0
- package/dist/generators/project.generator.d.ts +14 -0
- package/dist/generators/project.generator.d.ts.map +1 -0
- package/dist/generators/project.generator.js +497 -0
- package/dist/generators/project.generator.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/runners/k6.runner.d.ts +19 -0
- package/dist/runners/k6.runner.d.ts.map +1 -0
- package/dist/runners/k6.runner.js +127 -0
- package/dist/runners/k6.runner.js.map +1 -0
- package/dist/step-registry.d.ts +14 -0
- package/dist/step-registry.d.ts.map +1 -0
- package/dist/step-registry.js +36 -0
- package/dist/step-registry.js.map +1 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +40 -62
- package/LICENSE +0 -21
- package/bin/k6-cucumber-steps.js +0 -176
- package/docs/data/search.json +0 -1
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/global.html +0 -36
- package/docs/index.html +0 -91
- package/docs/k6-cucumber-steps/1.2.8/data/search.json +0 -1
- package/docs/k6-cucumber-steps/1.2.8/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/k6-cucumber-steps/1.2.8/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/k6-cucumber-steps/1.2.8/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/k6-cucumber-steps/1.2.8/global.html +0 -3
- package/docs/k6-cucumber-steps/1.2.8/helpers_generateHeaders.js.html +0 -38
- package/docs/k6-cucumber-steps/1.2.8/helpers_resolveBody.js.html +0 -65
- package/docs/k6-cucumber-steps/1.2.8/index.html +0 -91
- package/docs/k6-cucumber-steps/1.2.8/module-generateHeaders.html +0 -3
- package/docs/k6-cucumber-steps/1.2.8/module-resolveBody.html +0 -3
- package/docs/k6-cucumber-steps/1.2.8/scripts/core.js +0 -726
- package/docs/k6-cucumber-steps/1.2.8/scripts/core.min.js +0 -23
- package/docs/k6-cucumber-steps/1.2.8/scripts/resize.js +0 -90
- package/docs/k6-cucumber-steps/1.2.8/scripts/search.js +0 -265
- package/docs/k6-cucumber-steps/1.2.8/scripts/search.min.js +0 -6
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/Apache-License-2.0.txt +0 -202
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/fuse.js +0 -9
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/hljs-line-num-original.js +0 -369
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/hljs-line-num.js +0 -1
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/hljs-original.js +0 -5171
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/hljs.js +0 -1
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/popper.js +0 -5
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/tippy.js +0 -1
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/tocbot.js +0 -672
- package/docs/k6-cucumber-steps/1.2.8/scripts/third-party/tocbot.min.js +0 -1
- package/docs/k6-cucumber-steps/1.2.8/styles/clean-jsdoc-theme-base.css +0 -1159
- package/docs/k6-cucumber-steps/1.2.8/styles/clean-jsdoc-theme-dark.css +0 -412
- package/docs/k6-cucumber-steps/1.2.8/styles/clean-jsdoc-theme-light.css +0 -482
- package/docs/k6-cucumber-steps/1.2.8/styles/clean-jsdoc-theme-scrollbar.css +0 -30
- package/docs/k6-cucumber-steps/1.2.8/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -1
- package/docs/k6-cucumber-steps/1.2.8/styles/clean-jsdoc-theme.min.css +0 -1
- package/docs/k6-cucumber-steps/1.2.8/utils_k6Runner.js.html +0 -95
- package/docs/load_test_steps.js.html +0 -664
- package/docs/scripts/core.js +0 -726
- package/docs/scripts/core.min.js +0 -23
- package/docs/scripts/resize.js +0 -90
- package/docs/scripts/search.js +0 -265
- package/docs/scripts/search.min.js +0 -6
- package/docs/scripts/third-party/Apache-License-2.0.txt +0 -202
- package/docs/scripts/third-party/fuse.js +0 -9
- package/docs/scripts/third-party/hljs-line-num-original.js +0 -369
- package/docs/scripts/third-party/hljs-line-num.js +0 -1
- package/docs/scripts/third-party/hljs-original.js +0 -5171
- package/docs/scripts/third-party/hljs.js +0 -1
- package/docs/scripts/third-party/popper.js +0 -5
- package/docs/scripts/third-party/tippy.js +0 -1
- package/docs/scripts/third-party/tocbot.js +0 -672
- package/docs/scripts/third-party/tocbot.min.js +0 -1
- package/docs/styles/clean-jsdoc-theme-base.css +0 -1159
- package/docs/styles/clean-jsdoc-theme-dark.css +0 -412
- package/docs/styles/clean-jsdoc-theme-light.css +0 -482
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -30
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -1
- package/docs/styles/clean-jsdoc-theme.min.css +0 -1
- package/index.js +0 -1
- package/lib/helpers/buildK6Script.d.ts +0 -1
- package/lib/helpers/buildK6Script.js +0 -103
- package/lib/helpers/generateHeaders.d.ts +0 -5
- package/lib/helpers/generateHeaders.js +0 -48
- package/lib/helpers/resolveBody.d.ts +0 -2
- package/lib/helpers/resolveBody.js +0 -78
- package/lib/helpers/resolvePayloadPath.js +0 -25
- package/lib/helpers/runK6ScriptFromWorld.js +0 -26
- package/lib/utils/k6Runner.d.ts +0 -6
- package/lib/utils/k6Runner.js +0 -89
- package/scripts/cucumber.js +0 -18
- package/scripts/linkReports.js +0 -107
- package/step_definitions/load_test_steps.d.ts +0 -89
- package/step_definitions/load_test_steps.js +0 -689
- package/step_definitions/world.js +0 -41
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.K6Runner = void 0;
|
|
7
|
+
// src/runners/k6.runner.ts
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const util_1 = require("util");
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const feature_parser_1 = require("../generators/feature.parser");
|
|
13
|
+
const k6_script_generator_1 = require("../generators/k6-script.generator");
|
|
14
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
15
|
+
class K6Runner {
|
|
16
|
+
async runFromFeatures(featuresPath, outputScriptPath, options = {}) {
|
|
17
|
+
console.log("Loading and parsing feature files...");
|
|
18
|
+
const parser = new feature_parser_1.FeatureParser();
|
|
19
|
+
let features = await parser.loadAndParseFeatures(featuresPath);
|
|
20
|
+
// Apply tag filtering if specified
|
|
21
|
+
if (options.tags) {
|
|
22
|
+
const tagFilters = options.tags.split(",");
|
|
23
|
+
features = this.filterFeaturesByTags(features, tagFilters);
|
|
24
|
+
}
|
|
25
|
+
// Apply group filtering if specified
|
|
26
|
+
if (options.group) {
|
|
27
|
+
features = this.filterFeaturesByGroup(features, options.group);
|
|
28
|
+
}
|
|
29
|
+
console.log(`Found ${features.length} feature files`);
|
|
30
|
+
// Get all scenarios from filtered features
|
|
31
|
+
const allScenarios = features.flatMap((f) => f.scenarios);
|
|
32
|
+
console.log(`Processing ${allScenarios.length} scenarios`);
|
|
33
|
+
// Load metadata from scenarios
|
|
34
|
+
const metadata = parser.loadScenarioMetadata(allScenarios);
|
|
35
|
+
// Generate k6 script
|
|
36
|
+
const generator = new k6_script_generator_1.K6ScriptGenerator();
|
|
37
|
+
const config = {
|
|
38
|
+
language: options.language || "ts",
|
|
39
|
+
featuresDir: featuresPath,
|
|
40
|
+
outputDir: path_1.default.dirname(outputScriptPath || "./generated"),
|
|
41
|
+
includeHtmlReporter: true,
|
|
42
|
+
author: "Enyimiri Chetachi Paschal (qaPaschalE)",
|
|
43
|
+
version: require("../../package.json").version,
|
|
44
|
+
};
|
|
45
|
+
const k6Script = generator.generateK6File(allScenarios, metadata, config);
|
|
46
|
+
// Write the generated script
|
|
47
|
+
const finalOutputPath = outputScriptPath || `./generated/test.generated.${config.language}`;
|
|
48
|
+
const outputDir = path_1.default.dirname(finalOutputPath);
|
|
49
|
+
if (!fs_1.default.existsSync(outputDir)) {
|
|
50
|
+
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
51
|
+
}
|
|
52
|
+
fs_1.default.writeFileSync(finalOutputPath, k6Script);
|
|
53
|
+
console.log(`Generated k6 script: ${finalOutputPath}`);
|
|
54
|
+
// Run the k6 test
|
|
55
|
+
await this.runK6Test(finalOutputPath, options.additionalK6Options);
|
|
56
|
+
}
|
|
57
|
+
async runK6Test(scriptPath, additionalOptions) {
|
|
58
|
+
console.log("Running k6 test...");
|
|
59
|
+
const options = ["run", scriptPath];
|
|
60
|
+
if (additionalOptions) {
|
|
61
|
+
options.push(...additionalOptions);
|
|
62
|
+
}
|
|
63
|
+
const k6Command = `k6 ${options.join(" ")}`;
|
|
64
|
+
console.log(`Executing: ${k6Command}`);
|
|
65
|
+
try {
|
|
66
|
+
const { stdout, stderr } = await execAsync(k6Command);
|
|
67
|
+
if (stdout) {
|
|
68
|
+
console.log(stdout);
|
|
69
|
+
}
|
|
70
|
+
if (stderr) {
|
|
71
|
+
console.error(stderr);
|
|
72
|
+
}
|
|
73
|
+
console.log("K6 test completed successfully");
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error instanceof Error) {
|
|
77
|
+
console.error(`K6 test failed: ${error.message}`);
|
|
78
|
+
if (error.stderr) {
|
|
79
|
+
console.error(error.stderr);
|
|
80
|
+
}
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.error(`K6 test failed with unknown error:`, error);
|
|
85
|
+
throw new Error("K6 test execution failed");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async runGeneratedScript(scriptPath, options) {
|
|
90
|
+
if (!fs_1.default.existsSync(scriptPath)) {
|
|
91
|
+
throw new Error(`Generated script does not exist: ${scriptPath}`);
|
|
92
|
+
}
|
|
93
|
+
await this.runK6Test(scriptPath, options);
|
|
94
|
+
}
|
|
95
|
+
filterFeaturesByTags(features, tagFilters) {
|
|
96
|
+
return features
|
|
97
|
+
.map((feature) => ({
|
|
98
|
+
...feature,
|
|
99
|
+
scenarios: feature.scenarios.filter((scenario) => tagFilters.some((filter) => scenario.tags.includes(filter))),
|
|
100
|
+
}))
|
|
101
|
+
.filter((feature) => feature.scenarios.length > 0); // Remove features with no matching scenarios
|
|
102
|
+
}
|
|
103
|
+
filterFeaturesByGroup(features, group) {
|
|
104
|
+
return features
|
|
105
|
+
.map((feature) => ({
|
|
106
|
+
...feature,
|
|
107
|
+
scenarios: feature.scenarios.filter((scenario) => scenario.tags.some((tag) => tag.startsWith("group:") && tag.includes(group))),
|
|
108
|
+
}))
|
|
109
|
+
.filter((feature) => feature.scenarios.length > 0); // Remove features with no matching scenarios
|
|
110
|
+
}
|
|
111
|
+
async runWithFilters(featuresPath, filters) {
|
|
112
|
+
const additionalOptions = [];
|
|
113
|
+
if (filters.vus) {
|
|
114
|
+
additionalOptions.push(`--vus ${filters.vus}`);
|
|
115
|
+
}
|
|
116
|
+
if (filters.duration) {
|
|
117
|
+
additionalOptions.push(`--duration ${filters.duration}`);
|
|
118
|
+
}
|
|
119
|
+
await this.runFromFeatures(featuresPath, undefined, {
|
|
120
|
+
tags: filters.tags,
|
|
121
|
+
group: filters.group,
|
|
122
|
+
additionalK6Options: additionalOptions,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.K6Runner = K6Runner;
|
|
127
|
+
//# sourceMappingURL=k6.runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"k6.runner.js","sourceRoot":"","sources":["../../src/runners/k6.runner.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA2B;AAC3B,iDAAqC;AACrC,+BAAiC;AACjC,4CAAoB;AACpB,gDAAwB;AAExB,iEAA6D;AAC7D,2EAAsE;AAEtE,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAElC,MAAa,QAAQ;IACnB,KAAK,CAAC,eAAe,CACnB,YAAoB,EACpB,gBAAyB,EACzB,UAKI,EAAE;QAEN,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QAEpD,MAAM,MAAM,GAAG,IAAI,8BAAa,EAAE,CAAC;QACnC,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;QAE/D,mCAAmC;QACnC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3C,QAAQ,GAAG,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,UAAU,C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AAC,CAAC,QAAQ,EAAE,EAAE,CAC/C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAChB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzD,CACF;SACF,CAAC,CAAC;aACF,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,6CAA6C;IACrG,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,YAAoB,EACpB,OAKC;QAED,MAAM,iBAAiB,GAAG,EAAE,CAAC;QAE7B,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,iBAAiB,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACjD,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,iBAAiB,CAAC,IAAI,CAAC,cAAc,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,SAAS,EAAE;YAClD,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,mBAAmB,EAAE,iBAAiB;SACvC,CAAC,CAAC;IACL,CAAC;CACF;AA5KD,4BA4KC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const stepRegistry: {
|
|
2
|
+
givenSteps: Map<string, Function>;
|
|
3
|
+
whenSteps: Map<string, Function>;
|
|
4
|
+
thenSteps: Map<string, Function>;
|
|
5
|
+
andSteps: Map<string, Function>;
|
|
6
|
+
butSteps: Map<string, Function>;
|
|
7
|
+
};
|
|
8
|
+
export declare function Given(pattern: string, fn: Function): void;
|
|
9
|
+
export declare function When(pattern: string, fn: Function): void;
|
|
10
|
+
export declare function Then(pattern: string, fn: Function): void;
|
|
11
|
+
export declare function And(pattern: string, fn: Function): void;
|
|
12
|
+
export declare function But(pattern: string, fn: Function): void;
|
|
13
|
+
export { stepRegistry };
|
|
14
|
+
//# sourceMappingURL=step-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-registry.d.ts","sourceRoot":"","sources":["../src/step-registry.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,YAAY;;;;;;CAMjB,CAAC;AAEF,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAEzD;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAExD;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAExD;AAED,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAGvD;AAED,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAGvD;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stepRegistry = void 0;
|
|
4
|
+
exports.Given = Given;
|
|
5
|
+
exports.When = When;
|
|
6
|
+
exports.Then = Then;
|
|
7
|
+
exports.And = And;
|
|
8
|
+
exports.But = But;
|
|
9
|
+
// src/step-registry.ts (create this file)
|
|
10
|
+
// Internal registry to store step definitions
|
|
11
|
+
const stepRegistry = {
|
|
12
|
+
givenSteps: new Map(),
|
|
13
|
+
whenSteps: new Map(),
|
|
14
|
+
thenSteps: new Map(),
|
|
15
|
+
andSteps: new Map(),
|
|
16
|
+
butSteps: new Map(),
|
|
17
|
+
};
|
|
18
|
+
exports.stepRegistry = stepRegistry;
|
|
19
|
+
function Given(pattern, fn) {
|
|
20
|
+
stepRegistry.givenSteps.set(pattern, fn);
|
|
21
|
+
}
|
|
22
|
+
function When(pattern, fn) {
|
|
23
|
+
stepRegistry.whenSteps.set(pattern, fn);
|
|
24
|
+
}
|
|
25
|
+
function Then(pattern, fn) {
|
|
26
|
+
stepRegistry.thenSteps.set(pattern, fn);
|
|
27
|
+
}
|
|
28
|
+
function And(pattern, fn) {
|
|
29
|
+
// And is typically treated as When in Cucumber
|
|
30
|
+
stepRegistry.whenSteps.set(pattern, fn);
|
|
31
|
+
}
|
|
32
|
+
function But(pattern, fn) {
|
|
33
|
+
// But is typically treated as When in Cucumber
|
|
34
|
+
stepRegistry.whenSteps.set(pattern, fn);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=step-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-registry.js","sourceRoot":"","sources":["../src/step-registry.ts"],"names":[],"mappings":";;;AAUA,sBAEC;AAED,oBAEC;AAED,oBAEC;AAED,kBAGC;AAED,kBAGC;AA9BD,0CAA0C;AAC1C,8CAA8C;AAC9C,MAAM,YAAY,GAAG;IACnB,UAAU,EAAE,IAAI,GAAG,EAAoB;IACvC,SAAS,EAAE,IAAI,GAAG,EAAoB;IACtC,SAAS,EAAE,IAAI,GAAG,EAAoB;IACtC,QAAQ,EAAE,IAAI,GAAG,EAAoB;IACrC,QAAQ,EAAE,IAAI,GAAG,EAAoB;CACtC,CAAC;AAwBO,oCAAY;AAtBrB,SAAgB,KAAK,CAAC,OAAe,EAAE,EAAY;IACjD,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,SAAgB,IAAI,CAAC,OAAe,EAAE,EAAY;IAChD,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAgB,IAAI,CAAC,OAAe,EAAE,EAAY;IAChD,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAgB,GAAG,CAAC,OAAe,EAAE,EAAY;IAC/C,+CAA+C;IAC/C,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAgB,GAAG,CAAC,OAAe,EAAE,EAAY;IAC/C,+CAA+C;IAC/C,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DataTable, DocString } from "@cucumber/messages";
|
|
2
|
+
export interface FeatureFile {
|
|
3
|
+
path: string;
|
|
4
|
+
content: string;
|
|
5
|
+
scenarios: Scenario[];
|
|
6
|
+
}
|
|
7
|
+
export interface Scenario {
|
|
8
|
+
name: string;
|
|
9
|
+
steps: Step[];
|
|
10
|
+
tags: string[];
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Step {
|
|
14
|
+
keyword: string;
|
|
15
|
+
text: string;
|
|
16
|
+
argument?: DataTable | DocString;
|
|
17
|
+
}
|
|
18
|
+
export interface ScenarioMetadata {
|
|
19
|
+
scenarioName: string;
|
|
20
|
+
vus?: number;
|
|
21
|
+
duration?: string;
|
|
22
|
+
thresholds?: Record<string, any>;
|
|
23
|
+
tags: string[];
|
|
24
|
+
group?: string;
|
|
25
|
+
stages?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ProjectConfig {
|
|
28
|
+
language: "js" | "ts";
|
|
29
|
+
featuresDir: string;
|
|
30
|
+
outputDir: string;
|
|
31
|
+
includeHtmlReporter: boolean;
|
|
32
|
+
author: string;
|
|
33
|
+
version: string;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,IAAI;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "k6-cucumber-steps",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Generate k6 test scripts from Cucumber feature files",
|
|
5
|
+
"main": "dist/cli.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"k6-cucumber-steps": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "tsc --watch",
|
|
12
|
+
"start": "node dist/cli.js",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
6
16
|
"repository": {
|
|
7
17
|
"type": "git",
|
|
8
18
|
"url": "https://github.com/qaPaschalE/k6-cucumber-steps.git"
|
|
@@ -10,75 +20,43 @@
|
|
|
10
20
|
"bugs": {
|
|
11
21
|
"url": "https://github.com/qaPaschalE/k6-cucumber-steps/issues"
|
|
12
22
|
},
|
|
13
|
-
"type": "module",
|
|
14
23
|
"funding": {
|
|
15
24
|
"type": "github",
|
|
16
25
|
"url": "https://github.com/sponsors/qaPaschalE"
|
|
17
26
|
},
|
|
18
27
|
"homepage": "https://github.com/qaPaschalE/k6-cucumber-steps#readme",
|
|
19
|
-
"scripts": {
|
|
20
|
-
"stress": "npx cucumber-js --format json:stress-results.json --tags @stress",
|
|
21
|
-
"stress:report": "cucumber-html-reporter --jsonFile=stress-results.json --output=stress-report.html",
|
|
22
|
-
"loadTest": "npx cucumber-js --format json:reports/load-results.json --tags @loadTest",
|
|
23
|
-
"load:report": "cucumber-html-reporter --jsonFile=load-results.json --output=load-report.html",
|
|
24
|
-
"test": "cucumber-js features/ --require-module @babel/register --require step_definitions/",
|
|
25
|
-
"build": "npm run clean && npm run compile",
|
|
26
|
-
"clean": "rm -rf dist/",
|
|
27
|
-
"compile": "babel src/ -d dist/",
|
|
28
|
-
"docs": "jsdoc --configure jsdoc.json --verbose"
|
|
29
|
-
},
|
|
30
|
-
"cucumber": {
|
|
31
|
-
"require": [
|
|
32
|
-
"step_definitions/**/*.js"
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
"bin": {
|
|
36
|
-
"k6-cucumber-steps": "./bin/k6-cucumber-steps.js"
|
|
37
|
-
},
|
|
38
|
-
"files": [
|
|
39
|
-
"bin/",
|
|
40
|
-
"lib/",
|
|
41
|
-
"step_definitions/",
|
|
42
|
-
"scripts/",
|
|
43
|
-
"package.json",
|
|
44
|
-
"README.md",
|
|
45
|
-
"docs/",
|
|
46
|
-
"LICENSE"
|
|
47
|
-
],
|
|
48
28
|
"keywords": [
|
|
49
29
|
"k6",
|
|
50
30
|
"cucumber",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"steps",
|
|
57
|
-
"test-automation"
|
|
31
|
+
"gherkin",
|
|
32
|
+
"testing",
|
|
33
|
+
"performance",
|
|
34
|
+
"automation",
|
|
35
|
+
"bdd"
|
|
58
36
|
],
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
"author": "qaPaschalE <paschal.enyimiri@gmail.com>",
|
|
63
|
-
"description": "Cucumber step definitions for running k6 performance tests.",
|
|
64
|
-
"peerDependencies": {
|
|
65
|
-
"@cucumber/cucumber": "*",
|
|
66
|
-
"k6": "*"
|
|
67
|
-
},
|
|
37
|
+
"author": "Enyimiri Chetachi Paschal (qaPaschalE)",
|
|
38
|
+
"license": "MIT",
|
|
68
39
|
"dependencies": {
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"commander": "^14.0.0",
|
|
76
|
-
"dotenv": "^16.5.0",
|
|
77
|
-
"html-minifier-terser": "^7.2.0"
|
|
40
|
+
"@cucumber/cucumber": "^12.6.0",
|
|
41
|
+
"@cucumber/gherkin": "^26.2.0",
|
|
42
|
+
"@cucumber/messages": "^23.0.0",
|
|
43
|
+
"commander": "^14.0.2",
|
|
44
|
+
"gherkin": "^9.0.0",
|
|
45
|
+
"typescript": "^5.9.3"
|
|
78
46
|
},
|
|
79
47
|
"devDependencies": {
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
48
|
+
"@types/fs-extra": "^11.0.4",
|
|
49
|
+
"@types/jquery": "^3.5.33",
|
|
50
|
+
"@types/k6": "^1.5.0",
|
|
51
|
+
"@types/node": "^25.0.10",
|
|
52
|
+
"fs-extra": "^11.3.3",
|
|
53
|
+
"typedoc": "^0.25.4",
|
|
54
|
+
"typedoc-plugin-markdown": "^4.0.0"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"dist/**/*",
|
|
58
|
+
"templates/**/*",
|
|
59
|
+
"README.md",
|
|
60
|
+
"LICENSE"
|
|
61
|
+
]
|
|
84
62
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Enyimiri Chetachi Paschal
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of **k6-cucumber-steps** (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/bin/k6-cucumber-steps.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import path from "path";
|
|
3
|
-
import fs from "fs/promises";
|
|
4
|
-
import { spawn } from "child_process";
|
|
5
|
-
import { Command } from "commander";
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
import dotenv from "dotenv";
|
|
8
|
-
import { linkReports } from "../scripts/linkReports.js";
|
|
9
|
-
|
|
10
|
-
dotenv.config();
|
|
11
|
-
|
|
12
|
-
// Allow __dirname in ESM
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
-
const __dirname = path.dirname(__filename);
|
|
15
|
-
|
|
16
|
-
console.log(`
|
|
17
|
-
-----------------------------------------
|
|
18
|
-
🚀 Starting k6-cucumber-steps execution...
|
|
19
|
-
-----------------------------------------
|
|
20
|
-
`);
|
|
21
|
-
|
|
22
|
-
const program = new Command();
|
|
23
|
-
|
|
24
|
-
program
|
|
25
|
-
.command("run")
|
|
26
|
-
.option("-f, --feature <path>", "Feature file path")
|
|
27
|
-
.option("-t, --tags <string>", "Cucumber tags")
|
|
28
|
-
.option("-c, --config <file>", "Custom config file")
|
|
29
|
-
.option("--saveK6Script", "Keep generated k6 script files", false)
|
|
30
|
-
.option("--overwrite", "Overwrite report files", false)
|
|
31
|
-
.option("--cleanReports", "Clean the reports folder before running", false)
|
|
32
|
-
.option("--reporter", "Enable report generation", false)
|
|
33
|
-
.option("--clean", "Alias for --cleanReports", false)
|
|
34
|
-
.option("-p, --payloadPath <dir>", "Directory for payload files")
|
|
35
|
-
.option("--script <file>", "k6 script file to run")
|
|
36
|
-
.option("--k6Config <file>", "k6 config file to use")
|
|
37
|
-
.action(async (argv) => {
|
|
38
|
-
const configFileInput =
|
|
39
|
-
argv.config || process.env.CUCUMBER_CONFIG_FILE || "cucumber.js";
|
|
40
|
-
const configFilePath = path.isAbsolute(configFileInput)
|
|
41
|
-
? configFileInput
|
|
42
|
-
: path.resolve(process.cwd(), configFileInput);
|
|
43
|
-
|
|
44
|
-
let configOptions = {};
|
|
45
|
-
try {
|
|
46
|
-
const configModule = await import(pathToFileURL(configFilePath).href);
|
|
47
|
-
configOptions = configModule.default || configModule;
|
|
48
|
-
} catch (err) {
|
|
49
|
-
console.warn("⚠️ Could not load config file:", err.message);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const cucumberConfig = configOptions.default || configOptions;
|
|
53
|
-
const cliParts = [];
|
|
54
|
-
|
|
55
|
-
if (cucumberConfig.paths && Array.isArray(cucumberConfig.paths)) {
|
|
56
|
-
cliParts.push(...cucumberConfig.paths);
|
|
57
|
-
}
|
|
58
|
-
if (argv.feature) {
|
|
59
|
-
cliParts.push(argv.feature);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (cucumberConfig.import && Array.isArray(cucumberConfig.import)) {
|
|
63
|
-
cucumberConfig.import.forEach((imp) => cliParts.push("--import", imp));
|
|
64
|
-
}
|
|
65
|
-
if (cucumberConfig.require) {
|
|
66
|
-
console.warn(
|
|
67
|
-
"⚠️ 'require' is incompatible with ESM. Use 'import' instead."
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (cucumberConfig.format && Array.isArray(cucumberConfig.format)) {
|
|
72
|
-
cucumberConfig.format.forEach((fmt) => cliParts.push("--format", fmt));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (cucumberConfig.tags) {
|
|
76
|
-
cliParts.push("--tags", cucumberConfig.tags);
|
|
77
|
-
}
|
|
78
|
-
if (argv.tags) {
|
|
79
|
-
cliParts.push("--tags", argv.tags);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const projectRoot = process.cwd();
|
|
83
|
-
|
|
84
|
-
let payloadDirRaw =
|
|
85
|
-
argv.payloadPath ||
|
|
86
|
-
(cucumberConfig.worldParameters &&
|
|
87
|
-
cucumberConfig.worldParameters.payloadPath) ||
|
|
88
|
-
"payloads";
|
|
89
|
-
|
|
90
|
-
const payloadDir = path.resolve(projectRoot, payloadDirRaw);
|
|
91
|
-
console.log("📦 Resolved payload path:", payloadDir);
|
|
92
|
-
|
|
93
|
-
const worldParams = {
|
|
94
|
-
...(cucumberConfig.worldParameters || {}),
|
|
95
|
-
payloadPath: payloadDir,
|
|
96
|
-
};
|
|
97
|
-
cliParts.push("--world-parameters", JSON.stringify(worldParams));
|
|
98
|
-
|
|
99
|
-
if (argv.script) {
|
|
100
|
-
cliParts.push("--script", argv.script);
|
|
101
|
-
}
|
|
102
|
-
if (argv.k6Config) {
|
|
103
|
-
cliParts.push("--k6Config", argv.k6Config);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const finalCommand = ["npx", "cucumber-js", ...cliParts].join(" ");
|
|
107
|
-
console.log("▶️ Final arguments passed to cucumber-js:", finalCommand);
|
|
108
|
-
|
|
109
|
-
const extraEnv = {
|
|
110
|
-
SAVE_K6_SCRIPT:
|
|
111
|
-
cucumberConfig.saveK6Script === true || argv.saveK6Script === true
|
|
112
|
-
? "true"
|
|
113
|
-
: "false",
|
|
114
|
-
K6_CUCUMBER_OVERWRITE:
|
|
115
|
-
cucumberConfig.overwrite === true || argv.overwrite === true
|
|
116
|
-
? "true"
|
|
117
|
-
: "false",
|
|
118
|
-
CLEAN_REPORTS:
|
|
119
|
-
cucumberConfig.cleanReports === true ||
|
|
120
|
-
argv.cleanReports === true ||
|
|
121
|
-
argv.clean === true
|
|
122
|
-
? "true"
|
|
123
|
-
: "false",
|
|
124
|
-
K6_CUCUMBER_REPORTER:
|
|
125
|
-
cucumberConfig.reporter === true || argv.reporter === true
|
|
126
|
-
? "true"
|
|
127
|
-
: "false",
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const shouldCleanReports =
|
|
131
|
-
argv.cleanReports || argv.clean || cucumberConfig.cleanReports;
|
|
132
|
-
|
|
133
|
-
if (shouldCleanReports) {
|
|
134
|
-
const reportsDir = path.join(projectRoot, "reports");
|
|
135
|
-
try {
|
|
136
|
-
await fs.rm(reportsDir, { recursive: true, force: true });
|
|
137
|
-
await fs.mkdir(reportsDir, { recursive: true });
|
|
138
|
-
} catch (err) {
|
|
139
|
-
console.error("Failed to clean reports folder:", err.message);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const cucumberProcess = spawn("npx", ["cucumber-js", ...cliParts], {
|
|
144
|
-
stdio: "inherit",
|
|
145
|
-
env: { ...process.env, ...extraEnv },
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
cucumberProcess.on("close", async (code) => {
|
|
149
|
-
if (code === 0) {
|
|
150
|
-
console.log("-----------------------------------------");
|
|
151
|
-
console.log("✅ k6-cucumber-steps execution completed successfully.");
|
|
152
|
-
try {
|
|
153
|
-
await linkReports();
|
|
154
|
-
console.log(
|
|
155
|
-
"🔗 Reports linked successfully with embedded Cucumber tab."
|
|
156
|
-
);
|
|
157
|
-
} catch (err) {
|
|
158
|
-
console.error("⚠️ Failed to link reports:", err.message);
|
|
159
|
-
}
|
|
160
|
-
console.log("-----------------------------------------");
|
|
161
|
-
} else {
|
|
162
|
-
console.error("-----------------------------------------");
|
|
163
|
-
console.error("❌ k6-cucumber-steps execution failed.");
|
|
164
|
-
console.error("-----------------------------------------");
|
|
165
|
-
}
|
|
166
|
-
process.exit(code);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
program.parse(process.argv);
|
|
171
|
-
|
|
172
|
-
// Helper to handle dynamic import path
|
|
173
|
-
function pathToFileURL(p) {
|
|
174
|
-
const url = new URL("file://" + path.resolve(p));
|
|
175
|
-
return url;
|
|
176
|
-
}
|
package/docs/data/search.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"list":[{"title":"CustomWorld","link":"<a href=\"global.html#CustomWorld\">CustomWorld</a>"},{"title":"Given_I_set_k6_script_for_method_testing","link":"<a href=\"global.html#Given_I_set_k6_script_for_method_testing\">Given_I_set_k6_script_for_method_testing</a>","description":"<p>Initializes the k6 script configuration by setting the primary HTTP method for the load test.</p>\n<pre class=\"prettyprint source lang-gherkin\"><code>Given I set a k6 script for {word} testing\n</code></pre>"},{"title":"Given_I_set_k6_script_for_method_testing#config","link":"<a href=\"global.html#Given_I_set_k6_script_for_method_testing#config\">config</a>"},{"title":"K6Config","link":"<a href=\"global.html#K6Config\">K6Config</a>"},{"title":"Then_I_store_value_as_alias","link":"<a href=\"global.html#Then_I_store_value_as_alias\">Then_I_store_value_as_alias</a>","description":"<p>Stores a value from the last API response into the Cucumber World's aliases context.</p>\n<pre class=\"prettyprint source lang-gherkin\"><code>Then I store the value at "data.token" as alias "authToken"\n</code></pre>"},{"title":"When_I_login_via_POST_with_payload_from_file","link":"<a href=\"global.html#When_I_login_via_POST_with_payload_from_file\">When_I_login_via_POST_with_payload_from_file</a>","description":"<p>Logs in via a POST request to a specified endpoint using a JSON payload from a file.\nThe response data is stored for subsequent steps.</p>\n<pre class=\"prettyprint source lang-gherkin\"><code>When I login via POST to "/auth/login" with payload from "admin_credentials.json"\n</code></pre>"},{"title":"When_I_set_authentication_type","link":"<a href=\"global.html#When_I_set_authentication_type\">When_I_set_authentication_type</a>","description":"<p>Sets the authentication type for the k6 request, generating relevant headers.</p>\n<pre class=\"prettyprint source lang-gherkin\"><code>When I set the authentication type to "BearerToken"\n</code></pre>"},{"title":"When_I_set_endpoints_used","link":"<a href=\"global.html#When_I_set_endpoints_used\">When_I_set_endpoints_used</a>","description":"<p>Sets the list of endpoints to be used in the k6 script. These are typically used when\nthe k6 script iterates over multiple URLs.</p>\n<pre class=\"prettyprint source lang-gherkin\"><code>When I set the following endpoints used:\n/api/v1/users\n/api/v1/products\n/api/v1/orders\n</code></pre>"},{"title":"When_I_set_k6_script_configurations","link":"<a href=\"global.html#When_I_set_k6_script_configurations\">When_I_set_k6_script_configurations</a>","description":"<p>Configures the k6 script options (VUs, duration, stages, thresholds) from a data table.</p>\n<pre class=\"prettyprint source lang-gherkin\"><code>When I set to run the k6 script with the following configurations:\n| virtual_users | duration | stages | http_req_failed | http_req_duration | error_rate |\n| 10 | 30 | | p(99)<0.01 | p(99)<500 | rate<0.01 |\n| | | [{"duration":"10s","target":10}] | p(90)<0.01 | p(90)<200 | rate<0.001 |\n</code></pre>"},{"title":"When_I_set_method_body_for_endpoint","link":"<a href=\"global.html#When_I_set_method_body_for_endpoint\">When_I_set_method_body_for_endpoint</a>","description":"<p>Sets the request body for a specific HTTP method and endpoint.</p>\n<pre class=\"prettyprint source lang-gherkin\"><code>When I set the following POST body is used for "/api/v1/create"\n{ "name": "test", "email": "test@example.com" }\n</code></pre>"},{"title":"When_I_set_request_headers","link":"<a href=\"global.html#When_I_set_request_headers\">When_I_set_request_headers</a>","description":"<p>Sets request headers for the k6 script. Headers are merged with any existing headers.</p>\n<pre class=\"prettyprint source lang-gherkin\"><code>When I set the request headers:\n| Header | Value |\n| Content-Type | application/json |\n| Authorization | Bearer <my_token> |\n</code></pre>"},{"title":"When_I_use_JSON_payload_from_file_for_method_to_endpoint","link":"<a href=\"global.html#When_I_use_JSON_payload_from_file_for_method_to_endpoint\">When_I_use_JSON_payload_from_file_for_method_to_endpoint</a>","description":"<p>Loads a JSON payload from a file to be used as the request body for a specific\nmethod and endpoint in the k6 script.</p>\n<pre class=\"prettyprint source lang-gherkin\"><code>When I use JSON payload from "user_create.json" for POST to "/api/v1/users"\n</code></pre>"}]}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|