k6-cucumber-steps 1.0.11 → 1.0.12

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,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const path = require("path");
4
- const { runCucumber } = require("@cucumber/cucumber/api");
4
+ const { spawn } = require("child_process");
5
5
  require("dotenv").config();
6
-
7
6
  const argv = require("yargs")
8
7
  .usage("Usage: $0 run --feature <path> [options]")
9
8
  .option("feature", {
@@ -12,46 +11,56 @@ const argv = require("yargs")
12
11
  type: "string",
13
12
  demandOption: true,
14
13
  })
14
+ .option("tags", { alias: "t", describe: "Cucumber tags", type: "string" })
15
+ .option("reporter", {
16
+ alias: "r",
17
+ describe: "Generate reports",
18
+ type: "boolean",
19
+ default: false,
20
+ })
15
21
  .help().argv;
16
22
 
17
23
  const featureFilePath = path.resolve(process.cwd(), argv.feature);
24
+ const cucumberCommand = "npx";
25
+ const cucumberArgs = [
26
+ "cucumber-js",
27
+ featureFilePath,
28
+ "--require-module",
29
+ "@babel/register",
30
+ "--require",
31
+ path.resolve(
32
+ process.cwd(),
33
+ "node_modules",
34
+ "k6-cucumber-steps",
35
+ "step_definitions"
36
+ ),
37
+ "--format",
38
+ "summary",
39
+ ];
18
40
 
19
- async function main() {
20
- try {
21
- console.log(`Running tests for feature file: ${featureFilePath}`);
41
+ if (argv.tags) cucumberArgs.push("--tags", argv.tags);
42
+ if (argv.reporter) {
43
+ const reportsDir = path.resolve(process.cwd(), "reports");
44
+ cucumberArgs.push(
45
+ "--format",
46
+ `json:${reportsDir}/load-results.json`,
47
+ "--format",
48
+ `html:${reportsDir}/load-results.html`
49
+ );
50
+ }
22
51
 
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
- });
52
+ async function main() {
53
+ const fullCommand = `${cucumberCommand} ${cucumberArgs.join(" ")}`;
54
+ console.log(`Running Cucumber using command: ${fullCommand}`);
41
55
 
42
- if (!result.success) {
43
- console.error("K6 Cucumber tests failed.");
44
- process.exit(1);
45
- }
56
+ const cucumberProcess = spawn(cucumberCommand, cucumberArgs, {
57
+ cwd: process.cwd(),
58
+ stdio: "inherit",
59
+ });
46
60
 
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
- }
61
+ cucumberProcess.on("close", (code) => {
62
+ process.exit(code);
63
+ });
52
64
  }
53
65
 
54
- main().catch((err) => {
55
- console.error("An unexpected error occurred:", err);
56
- process.exit(1);
57
- });
66
+ main().catch((err) => console.error(err));
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "main": "index.js",
5
+ "license": "MIT",
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "https://github.com/qaPaschalE/k6-cucumber-steps.git"
@@ -43,7 +44,6 @@
43
44
  "node": ">=18"
44
45
  },
45
46
  "author": "qaPaschalE",
46
- "license": "ISC",
47
47
  "description": "Cucumber step definitions for running k6 performance tests.",
48
48
  "devDependencies": {
49
49
  "@babel/cli": "^7.27.0",