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