k6-cucumber-steps 1.0.9 → 1.0.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.
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const fs = require("fs");
|
|
4
3
|
const path = require("path");
|
|
5
4
|
const { spawn } = require("child_process");
|
|
6
5
|
require("dotenv").config();
|
|
7
|
-
|
|
8
|
-
// Use yargs for better argument parsing
|
|
9
6
|
const argv = require("yargs")
|
|
10
7
|
.usage("Usage: $0 run --feature <path> [options]")
|
|
11
8
|
.option("feature", {
|
|
@@ -14,24 +11,19 @@ const argv = require("yargs")
|
|
|
14
11
|
type: "string",
|
|
15
12
|
demandOption: true,
|
|
16
13
|
})
|
|
17
|
-
.option("tags", {
|
|
18
|
-
alias: "t",
|
|
19
|
-
describe:
|
|
20
|
-
"Cucumber tags to filter scenarios (e.g., '@smoke and not @integration')",
|
|
21
|
-
type: "string",
|
|
22
|
-
})
|
|
14
|
+
.option("tags", { alias: "t", describe: "Cucumber tags", type: "string" })
|
|
23
15
|
.option("reporter", {
|
|
24
16
|
alias: "r",
|
|
25
|
-
describe: "Generate
|
|
17
|
+
describe: "Generate reports",
|
|
26
18
|
type: "boolean",
|
|
27
19
|
default: false,
|
|
28
20
|
})
|
|
29
21
|
.help().argv;
|
|
30
22
|
|
|
31
23
|
const featureFilePath = path.resolve(process.cwd(), argv.feature);
|
|
32
|
-
const cucumberCommand = "npx";
|
|
24
|
+
const cucumberCommand = "npx";
|
|
33
25
|
const cucumberArgs = [
|
|
34
|
-
"cucumber-js",
|
|
26
|
+
"cucumber-js",
|
|
35
27
|
featureFilePath,
|
|
36
28
|
"--require-module",
|
|
37
29
|
"@babel/register",
|
|
@@ -46,15 +38,15 @@ const cucumberArgs = [
|
|
|
46
38
|
"summary",
|
|
47
39
|
];
|
|
48
40
|
|
|
49
|
-
if (argv.tags)
|
|
50
|
-
cucumberArgs.push("--tags", argv.tags);
|
|
51
|
-
}
|
|
52
|
-
|
|
41
|
+
if (argv.tags) cucumberArgs.push("--tags", argv.tags);
|
|
53
42
|
if (argv.reporter) {
|
|
54
43
|
const reportsDir = path.resolve(process.cwd(), "reports");
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
cucumberArgs.push(
|
|
45
|
+
"--format",
|
|
46
|
+
`json:${reportsDir}/load-results.json`,
|
|
47
|
+
"--format",
|
|
48
|
+
`html:${reportsDir}/load-results.html`
|
|
49
|
+
);
|
|
58
50
|
}
|
|
59
51
|
|
|
60
52
|
async function main() {
|
|
@@ -63,22 +55,12 @@ async function main() {
|
|
|
63
55
|
|
|
64
56
|
const cucumberProcess = spawn(cucumberCommand, cucumberArgs, {
|
|
65
57
|
cwd: process.cwd(),
|
|
66
|
-
stdio: "inherit",
|
|
58
|
+
stdio: "inherit",
|
|
67
59
|
});
|
|
68
60
|
|
|
69
61
|
cucumberProcess.on("close", (code) => {
|
|
70
|
-
|
|
71
|
-
console.error(`Cucumber process exited with code ${code}`);
|
|
72
|
-
process.exit(code);
|
|
73
|
-
} else {
|
|
74
|
-
console.log(
|
|
75
|
-
"Cucumber tests finished successfully. Check k6 output for performance results (if any steps ran k6)."
|
|
76
|
-
);
|
|
77
|
-
}
|
|
62
|
+
process.exit(code);
|
|
78
63
|
});
|
|
79
64
|
}
|
|
80
65
|
|
|
81
|
-
main().catch((err) =>
|
|
82
|
-
console.error("An unexpected error occurred:", err.message);
|
|
83
|
-
process.exit(1);
|
|
84
|
-
});
|
|
66
|
+
main().catch((err) => console.error(err));
|