k6-cucumber-steps 1.1.9 → 1.1.10

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.
@@ -77,7 +77,8 @@ program
77
77
  // Determine payload directory from CLI or config, always relative to project root
78
78
  let payloadDirRaw =
79
79
  argv.payloadPath ||
80
- (cucumberConfig.worldParameters && cucumberConfig.worldParameters.payloadPath) ||
80
+ (cucumberConfig.worldParameters &&
81
+ cucumberConfig.worldParameters.payloadPath) ||
81
82
  "payloads";
82
83
  const payloadDir = path.isAbsolute(payloadDirRaw)
83
84
  ? payloadDirRaw
@@ -95,6 +96,22 @@ program
95
96
  const finalCommand = ["npx", "cucumber-js", ...cliParts].join(" ");
96
97
  console.log("▶️ Final arguments passed to cucumber-js:", finalCommand);
97
98
 
99
+ // Clean reports directory if requested
100
+ const shouldCleanReports =
101
+ argv.cleanReports ||
102
+ argv.clean ||
103
+ process.env.CLEAN_REPORTS === "true" ||
104
+ cucumberConfig.cleanReports;
105
+
106
+ if (shouldCleanReports) {
107
+ const reportsDir = path.join(projectRoot, "reports");
108
+ if (fs.existsSync(reportsDir)) {
109
+ fs.rmSync(reportsDir, { recursive: true, force: true });
110
+ fs.mkdirSync(reportsDir, { recursive: true });
111
+ console.log("🧹 Cleaned reports directory.");
112
+ }
113
+ }
114
+
98
115
  // Now spawn the process
99
116
  const cucumberProcess = spawn("npx", ["cucumber-js", ...cliParts], {
100
117
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,38 +10,58 @@ async function linkReports() {
10
10
  return;
11
11
  }
12
12
 
13
+ // Get all HTML files in the reports directory
13
14
  const htmlFiles = fs
14
15
  .readdirSync(reportsDir)
15
- .filter((f) => f.endsWith(".html"));
16
- const k6ReportFile = htmlFiles.find(
17
- (f) => f.startsWith("k6-report") && f.endsWith(".html")
18
- );
19
- const cucumberReportFile = htmlFiles.find((f) =>
20
- f.includes("cucumber-report")
21
- );
16
+ .filter((f) => f.endsWith(".html"))
17
+ .map((f) => ({
18
+ name: f,
19
+ path: path.join(reportsDir, f),
20
+ mtime: fs.statSync(path.join(reportsDir, f)).mtime.getTime(),
21
+ }));
22
+
23
+ if (htmlFiles.length === 0) {
24
+ console.warn("⚠️ No HTML reports found.");
25
+ return;
26
+ }
27
+
28
+ // Find k6 report: file starting with "k6-" or fallback to most recent
29
+ let k6Report = htmlFiles.find((f) => f.name.startsWith("k6-"));
30
+ if (!k6Report) {
31
+ k6Report = htmlFiles.reduce((a, b) => (a.mtime > b.mtime ? a : b));
32
+ }
33
+
34
+ // Find all other HTML reports (excluding k6 report)
35
+ const otherReports = htmlFiles.filter((f) => f.name !== k6Report.name);
22
36
 
23
- if (!k6ReportFile || !cucumberReportFile) {
24
- console.warn("⚠️ K6 or Cucumber HTML report not found.");
37
+ if (!k6Report || otherReports.length === 0) {
38
+ console.warn("⚠️ K6 or any other HTML report not found.");
25
39
  return;
26
40
  }
27
41
 
28
- const k6Path = path.join(reportsDir, k6ReportFile);
29
- const cucumberPath = path.basename(cucumberReportFile);
30
- let content = fs.readFileSync(k6Path, "utf8");
42
+ // Read k6 report content
43
+ let content = fs.readFileSync(k6Report.path, "utf8");
31
44
 
32
- const cucumberTab = `
33
- <input type="radio" name="tabs" id="tabcucumber">
34
- <label for="tabcucumber"><i class="fas fa-file-alt"></i> &nbsp; Cucumber Report</label>
45
+ // Build tabs for each other report
46
+ const tabs = otherReports
47
+ .map(
48
+ (report, idx) => `
49
+ <input type="radio" name="tabs" id="tab${idx + 2}">
50
+ <label for="tab${idx + 2}"><i class="fas fa-file-alt"></i> &nbsp; ${report.name}</label>
35
51
  <div class="tab">
36
- <iframe src="${cucumberPath}" style="width:100%; height:600px; border:none;"></iframe>
52
+ <iframe src="${report.name}" style="width:100%; height:600px; border:none;"></iframe>
37
53
  </div>
38
- `;
54
+ `
55
+ )
56
+ .join("\n");
39
57
 
58
+ // Insert tabs after the first tab (assumes k6 report has a tab structure)
40
59
  content = content.replace(
41
60
  /<input type="radio" name="tabs" id="tabone"/,
42
- `${cucumberTab}\n<input type="radio" name="tabs" id="tabone"`
61
+ `${tabs}\n<input type="radio" name="tabs" id="tabone"`
43
62
  );
44
63
 
64
+ // Remove any existing footer
45
65
  content = content.replace(
46
66
  /<div style="padding:10px;margin-top:20px;text-align:center">[\s\S]*?<\/div>/,
47
67
  ""