k6-cucumber-steps 1.1.7 → 1.1.8

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.
@@ -19,110 +19,107 @@ program
19
19
  .command("run")
20
20
  .option("-f, --feature <path>", "Feature file path")
21
21
  .option("-t, --tags <string>", "Cucumber tags")
22
- .option("-c, --config <file>", "Custom config file") // changed from --configFile to --config
22
+ .option("-c, --config <file>", "Custom config file")
23
23
  .option("-r, --reporter", "Enable report generation", false)
24
24
  .option("-o, --overwrite", "Overwrite report files", false)
25
25
  .option("--cleanReports", "Clean the reports folder before running")
26
- .option("--clean", "Alias for --cleanReports");
27
-
28
- program.parse(process.argv);
29
-
30
- const argv = program.opts();
31
-
32
- const cucumberArgs = ["cucumber-js"];
33
-
34
- // Update all references to argv.configFile to argv.config:
35
- const configFileInput =
36
- argv.config || process.env.CUCUMBER_CONFIG_FILE || "cucumber.js";
37
- const configFilePath = path.isAbsolute(configFileInput)
38
- ? configFileInput
39
- : path.resolve(process.cwd(), configFileInput);
40
-
41
- let configOptions = {};
42
-
43
- if (fs.existsSync(configFilePath)) {
44
- cucumberArgs.push("--config", configFileInput);
45
- try {
46
- const loadedConfig = require(configFilePath);
47
- configOptions = loadedConfig.default || loadedConfig;
48
- } catch (err) {
49
- console.warn("⚠️ Could not load config file:", err.message);
50
- }
51
- } else {
52
- console.warn(`⚠️ Config file not found at ${configFilePath}`);
53
- }
54
-
55
- // Resolve cleanReports: CLI > ENV > config file
56
- const cleanReports =
57
- typeof argv.cleanReports === "boolean"
58
- ? argv.cleanReports
59
- : typeof argv.clean === "boolean"
60
- ? argv.clean
61
- : process.env.CLEAN_REPORTS
62
- ? process.env.CLEAN_REPORTS === "true"
63
- : configOptions.cleanReports;
64
-
65
- // Clean reports directory if needed
66
- const reportsDir = path.resolve("reports");
67
- if (cleanReports) {
68
- if (fs.existsSync(reportsDir)) {
69
- fs.rmSync(reportsDir, { recursive: true, force: true });
70
- console.log("🧹 Cleaned reports directory.");
71
- }
72
- }
73
- if (!fs.existsSync(reportsDir)) {
74
- fs.mkdirSync(reportsDir, { recursive: true });
75
- }
26
+ .option("--clean", "Alias for --cleanReports")
27
+ .action(async (argv) => {
28
+ const cucumberArgs = ["cucumber-js"];
29
+ const configFileInput =
30
+ argv.config || process.env.CUCUMBER_CONFIG_FILE || "cucumber.js";
31
+ const configFilePath = path.isAbsolute(configFileInput)
32
+ ? configFileInput
33
+ : path.resolve(process.cwd(), configFileInput);
34
+
35
+ let configOptions = {};
36
+
37
+ if (fs.existsSync(configFilePath)) {
38
+ cucumberArgs.push("--config", configFileInput);
39
+ try {
40
+ const loadedConfig = require(configFilePath);
41
+ configOptions = loadedConfig.default || loadedConfig;
42
+ } catch (err) {
43
+ console.warn("⚠️ Could not load config file:", err.message);
44
+ }
45
+ } else {
46
+ console.warn(`⚠️ Config file not found at ${configFilePath}`);
47
+ }
76
48
 
77
- // Build featureFiles array before using it
78
- let featureFiles = [];
79
- if (argv.feature) {
80
- featureFiles.push(path.resolve(argv.feature));
81
- } else if (Array.isArray(configOptions.paths)) {
82
- featureFiles = configOptions.paths.map((f) => path.resolve(f));
83
- }
49
+ // Resolve cleanReports: CLI > ENV > config file
50
+ const cleanReports =
51
+ typeof argv.cleanReports === "boolean"
52
+ ? argv.cleanReports
53
+ : typeof argv.clean === "boolean"
54
+ ? argv.clean
55
+ : process.env.CLEAN_REPORTS
56
+ ? process.env.CLEAN_REPORTS === "true"
57
+ : configOptions.cleanReports;
58
+
59
+ // Clean reports directory if needed
60
+ const reportsDir = path.resolve("reports");
61
+ if (cleanReports) {
62
+ if (fs.existsSync(reportsDir)) {
63
+ fs.rmSync(reportsDir, { recursive: true, force: true });
64
+ console.log("🧹 Cleaned reports directory.");
65
+ }
66
+ }
67
+ if (!fs.existsSync(reportsDir)) {
68
+ fs.mkdirSync(reportsDir, { recursive: true });
69
+ }
84
70
 
85
- let baseReportName = "load-report";
86
- if (featureFiles.length === 1) {
87
- baseReportName = path.basename(featureFiles[0], ".feature");
88
- } else if (featureFiles.length > 1) {
89
- baseReportName = "multi-feature";
90
- }
91
- const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
92
- let reportHtmlPath = path.join(reportsDir, `cucumber-report.html`);
71
+ // Build featureFiles array before using it
72
+ let featureFiles = [];
73
+ if (argv.feature) {
74
+ featureFiles.push(path.resolve(argv.feature));
75
+ } else if (Array.isArray(configOptions.paths)) {
76
+ featureFiles = configOptions.paths.map((f) => path.resolve(f));
77
+ }
93
78
 
94
- if (argv.reporter && !Array.isArray(configOptions.format)) {
95
- cucumberArgs.push("--format", "summary");
96
- cucumberArgs.push("--format", `html:${reportHtmlPath}`);
97
- }
79
+ let baseReportName = "load-report";
80
+ if (featureFiles.length === 1) {
81
+ baseReportName = path.basename(featureFiles[0], ".feature");
82
+ } else if (featureFiles.length > 1) {
83
+ baseReportName = "multi-feature";
84
+ }
85
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
86
+ let reportHtmlPath = path.join(reportsDir, `cucumber-report.html`);
98
87
 
99
- console.log("\n▶️ Final arguments passed to cucumber-js:");
100
- console.log(["npx", ...cucumberArgs].join(" ") + "\n");
88
+ if (argv.reporter && !Array.isArray(configOptions.format)) {
89
+ cucumberArgs.push("--format", "summary");
90
+ cucumberArgs.push("--format", `html:${reportHtmlPath}`);
91
+ }
101
92
 
102
- const cucumberProcess = spawn("npx", cucumberArgs, {
103
- stdio: "inherit",
104
- env: {
105
- ...process.env,
106
- REPORT_HTML_PATH: reportHtmlPath,
107
- K6_CUCUMBER_OVERWRITE: argv.overwrite ? "true" : "false",
108
- },
109
- });
93
+ console.log("\n▶️ Final arguments passed to cucumber-js:");
94
+ console.log(["npx", ...cucumberArgs].join(" ") + "\n");
95
+
96
+ const cucumberProcess = spawn("npx", cucumberArgs, {
97
+ stdio: "inherit",
98
+ env: {
99
+ ...process.env,
100
+ REPORT_HTML_PATH: reportHtmlPath,
101
+ K6_CUCUMBER_OVERWRITE: argv.overwrite ? "true" : "false",
102
+ },
103
+ });
104
+
105
+ cucumberProcess.on("close", async (code) => {
106
+ if (code === 0) {
107
+ console.log("-----------------------------------------");
108
+ console.log("✅ k6-cucumber-steps execution completed successfully.");
109
+ try {
110
+ await linkReports();
111
+ console.log("🔗 Reports linked successfully with embedded Cucumber tab.");
112
+ } catch (err) {
113
+ console.error("⚠️ Failed to link reports:", err.message);
114
+ }
115
+ console.log("-----------------------------------------");
116
+ } else {
117
+ console.error("-----------------------------------------");
118
+ console.error("❌ k6-cucumber-steps execution failed.");
119
+ console.error("-----------------------------------------");
120
+ }
121
+ process.exit(code);
122
+ });
123
+ });
110
124
 
111
- cucumberProcess.on("close", async (code) => {
112
- if (code === 0) {
113
- console.log("-----------------------------------------");
114
- console.log("✅ k6-cucumber-steps execution completed successfully.");
115
- try {
116
- await linkReports();
117
- console.log("🔗 Reports linked successfully with embedded Cucumber tab.");
118
- } catch (err) {
119
- console.error("⚠️ Failed to link reports:", err.message);
120
- }
121
- console.log("-----------------------------------------");
122
- } else {
123
- console.error("-----------------------------------------");
124
- console.error("❌ k6-cucumber-steps execution failed.");
125
- console.error("-----------------------------------------");
126
- }
127
- process.exit(code);
128
- });
125
+ program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -0,0 +1,18 @@
1
+ module.exports = {
2
+ default: {
3
+ require: ["./step_definitions/**/*.js"],
4
+ format: [
5
+ "summary",
6
+ "json:./reports/load-report.json",
7
+ "html:./reports/cucumber-report.html",
8
+ ],
9
+ paths: ["./features/bsp.feature"],
10
+ tags: "@get",
11
+ cleanReports: true,
12
+ worldParameters: {
13
+ payloadPath: "payloads",
14
+ },
15
+ overwrite: true,
16
+ reporter: true,
17
+ },
18
+ };