k6-cucumber-steps 1.1.5 → 1.1.7

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.
package/README.md CHANGED
@@ -5,12 +5,14 @@
5
5
  </td></tr></table>
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/k6-cucumber-steps.svg)](https://www.npmjs.com/package/k6-cucumber-steps)
8
- [![npm downloads](https://img.shields.io/npm/dt/k6-cucumber-steps.svg)](https://www.npmjs.com/package/k6-cucumber-steps)
9
- [![license](https://img.shields.io/npm/l/k6-cucumber-steps)](https://github.com/qaPaschalE/k6-cucumber-steps/blob/main/LICENSE)
10
- [![Cucumber](https://img.shields.io/badge/built%20with-Cucumber-3178c6.svg)](https://cucumber.io/)
8
+ [![Built with k6](https://img.shields.io/badge/built%20with-k6-7D64FF?logo=k6&logoColor=white&style=flat-square)](https://k6.io/)
9
+ [![license](https://img.shields.io/npm/l/k6-cucumber-steps?logo=github)](https://github.com/qaPaschalE/k6-cucumber-steps/blob/main/LICENSE)
10
+ [![Built for Cucumber](https://img.shields.io/badge/built%20for-Cucumber-23d96c?logo=cucumber&logoColor=white&style=flat-square)](https://cucumber.io/)
11
11
  [![Node.js](https://img.shields.io/badge/node-%3E=18-green.svg)](https://nodejs.org/)
12
- [![Sponsor](https://img.shields.io/github/sponsors/qaPaschalE?style=social)](https://github.com/sponsors/qaPaschalE)
13
- [![Build Status](https://github.com/qaPaschalE/k6-cucumber-steps/actions/workflows/k6-load-test.yml/badge.svg)](https://github.com/aPaschalE/k6-cucumber-steps/actions/workflows/k6-load-test.yml)
12
+ [![Build Status](https://github.com/qaPaschalE/k6-cucumber-steps/actions/workflows/k6-load-test.yml/badge.svg)](https://github.com/qaPaschalE/k6-cucumber-steps/actions/workflows/k6-load-test.yml)
13
+ [![Issues](https://img.shields.io/github/issues/qaPaschalE/k6-cucumber-steps?style=flat-square)](https://github.com/qaPaschalE/k6-cucumber-steps/issues)
14
+ [![Stars](https://img.shields.io/github/stars/qaPaschalE/k6-cucumber-steps?style=flat-square)](https://github.com/qaPaschalE/k6-cucumber-steps/stargazers)
15
+ [![npm downloads](https://img.shields.io/npm/dt/k6-cucumber-steps?logo=download&logoColor=white&style=flat-square)](https://www.npmjs.com/package/k6-cucumber-steps)
14
16
 
15
17
  Run [k6](https://k6.io/) performance/load tests using [Cucumber](https://cucumber.io/) BDD syntax with ease.
16
18
 
@@ -18,20 +20,19 @@ Run [k6](https://k6.io/) performance/load tests using [Cucumber](https://cucumbe
18
20
 
19
21
  ## ✨ Features
20
22
 
21
- - ✅ Cucumber + Gherkin for writing k6 tests
22
- to generate JSON and HTML reports.
23
+ - ✅ Cucumber + Gherkin for writing k6 tests to generate JSON and HTML reports.
23
24
  - ✅ Flexible configuration through Cucumber data tables.
24
- - ✅ Support for JSON body parsing and escaping
25
+ - ✅ Support for JSON body parsing and escaping.
25
26
  - ✅ Dynamic request body generation using environment variables, Faker templates, and JSON file includes.
26
27
  - ✅ `.env` + `K6.env`-style variable resolution (`{{API_KEY}}`)
27
- - ✅ Support for headers, query params, stages
28
+ - ✅ Support for headers, query params, stages.
28
29
  - ✅ Supports multiple authentication types: API key, Bearer token, Basic Auth, and No Auth.
29
-
30
- - ✅ Clean-up of temporary k6 files after execution
31
- - ✅ Built-in support for **distributed load testing** with stages
30
+ - ✅ Clean-up of temporary k6 files after execution.
31
+ - ✅ Built-in support for **distributed load testing** with stages.
32
32
  - ✅ TypeScript-first 🧡
33
33
  - ✅ **Optional report overwriting**: Use the `overwrite` option to control whether reports are overwritten or appended.
34
- - ✅ **Generate detailed reports**: Use the `--reporter` flag
34
+ - ✅ **Generate detailed reports**: Use the `--reporter` flag.
35
+ - ✅ **Clean reports directory before run**: Use the `--cleanReports`/`--clean` CLI flag, `CLEAN_REPORTS=true` in `.env`, or `cleanReports: true` in your `cucumber.js` config.
35
36
 
36
37
  ---
37
38
 
@@ -55,6 +56,7 @@ The `run` command accepts the following options:
55
56
 
56
57
  - `-f, --feature <path>`: Path to the feature file to execute.
57
58
  - `-t, --tags <string>`: Cucumber tags to filter scenarios (e.g., `@smoke and not @regression`).
59
+ - `-c, --config <file>`: Custom config file (default: `cucumber.js`).
58
60
  - `-r, --reporter`: Generate HTML and JSON reports in the `reports` directory. This is a boolean flag, so just include `-r, --reporter` to enable it.
59
61
  - `-o, --overwrite`: Overwrite existing reports instead of appending them.
60
62
  - `--cleanReports`, `--clean`: **Clean the `reports` directory before running.**
@@ -75,9 +77,9 @@ Here's a step-by-step guide to using `k6-cucumber-steps` in your project:
75
77
  **Prerequisites:**
76
78
 
77
79
  1. **Node.js and npm (or yarn):** Ensure you have Node.js and npm (or yarn) installed.
78
- 2. **k6:** Install k6 on your system following the instructions at [k6.io/docs/getting-started/installation/](https://www.google.com/search?q=https://k6.io/docs/getting-started/installation/).
79
- 3. **@cucumber/cucumber:(optional)** This package is required for using Cucumber.
80
- 4. **cucumber-html-reporter:(optional)** This package is needed if you intend to generate detailed HTML reports
80
+ 2. **k6:** Install k6 on your system following the instructions at [k6.io/docs/getting-started/installation/](https://k6.io/docs/getting-started/installation/).
81
+ 3. **@cucumber/cucumber (optional):** This package is required for using Cucumber.
82
+ 4. **cucumber-html-reporter (optional):** This package is needed if you intend to generate detailed HTML reports.
81
83
 
82
84
  **Setup:**
83
85
 
@@ -127,7 +129,7 @@ Here's a step-by-step guide to using `k6-cucumber-steps` in your project:
127
129
  paths: ["./features/*.feature"],
128
130
  tags: process.env.TAGS,
129
131
  worldParameters: {
130
- payloadPath: "apps/qa/performance/payloads"
132
+ payloadPath: "apps/qa/performance/payloads",
131
133
  },
132
134
  overwrite: false, // Default to not overwrite the report file
133
135
  cleanReports: true, // <--- Clean the reports directory before running
@@ -156,8 +158,8 @@ Priority order: **CLI > Environment variable > Config file**
156
158
  1. **Environment Variables**: Create a `.env` file in your project root based on the provided `.env.example`:
157
159
 
158
160
  ```env
159
- BASE_URL=[https://api.example.com](https://api.example.com)
160
- API_BASE_URL=[https://api.example.com](https://api.example.com)
161
+ BASE_URL=https://api.example.com
162
+ API_BASE_URL=https://api.example.com
161
163
  API_KEY=your_api_key
162
164
  BEARER_TOKEN=your_bearer_token
163
165
  BASIC_USER=your_basic_user
@@ -184,7 +186,7 @@ Feature: API Performance Testing
184
186
  And I set the following endpoints used:
185
187
  """
186
188
  /api/profile
187
- [https://reqres.in/api/users?page=2](https://reqres.in/api/users?page=2)
189
+ https://reqres.in/api/users?page=2
188
190
  """
189
191
  And I set the authentication type to "none"
190
192
  Then I see the API should handle the GET request successfully
@@ -238,7 +240,6 @@ When I set the request headers:
238
240
  When I set the following endpoints used:
239
241
  When I set the following {word} body is used for {string}
240
242
  When I store the value at {string} as alias {string}
241
-
242
243
  ```
243
244
 
244
245
  ### Assertion Steps
@@ -276,7 +277,4 @@ If you find this package useful, consider [sponsoring me on GitHub](https://gith
276
277
 
277
278
  MIT License - [@qaPaschalE](https://github.com/qaPaschalE)
278
279
 
279
-
280
- ## License
281
-
282
280
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -2,8 +2,7 @@
2
2
  const path = require("path");
3
3
  const fs = require("fs");
4
4
  const { spawn } = require("child_process");
5
- const yargs = require("yargs/yargs");
6
- const { hideBin } = require("yargs/helpers");
5
+ const { Command } = require("commander");
7
6
  require("dotenv").config();
8
7
 
9
8
  const { linkReports } = require("../scripts/linkReports");
@@ -14,41 +13,27 @@ console.log(`
14
13
  -----------------------------------------
15
14
  `);
16
15
 
17
- const argv = yargs(hideBin(process.argv))
18
- .option("feature", {
19
- alias: "f",
20
- type: "string",
21
- describe: "Feature file path",
22
- })
23
- .option("tags", { alias: "t", type: "string", describe: "Cucumber tags" })
24
- .option("configFile", {
25
- alias: "c",
26
- type: "string",
27
- describe: "Custom config file",
28
- })
29
- .option("reporter", {
30
- alias: "r",
31
- type: "boolean",
32
- default: false,
33
- describe: "Enable report generation",
34
- })
35
- .option("overwrite", {
36
- alias: "o",
37
- type: "boolean",
38
- default: false,
39
- describe: "Overwrite report files",
40
- })
41
- .option("cleanReports", {
42
- alias: "clean",
43
- type: "boolean",
44
- describe: "Clean the reports folder before running",
45
- })
46
- .help().argv;
16
+ const program = new Command();
17
+
18
+ program
19
+ .command("run")
20
+ .option("-f, --feature <path>", "Feature file path")
21
+ .option("-t, --tags <string>", "Cucumber tags")
22
+ .option("-c, --config <file>", "Custom config file") // changed from --configFile to --config
23
+ .option("-r, --reporter", "Enable report generation", false)
24
+ .option("-o, --overwrite", "Overwrite report files", false)
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();
47
31
 
48
32
  const cucumberArgs = ["cucumber-js"];
49
33
 
34
+ // Update all references to argv.configFile to argv.config:
50
35
  const configFileInput =
51
- argv.configFile || process.env.CUCUMBER_CONFIG_FILE || "cucumber.js";
36
+ argv.config || process.env.CUCUMBER_CONFIG_FILE || "cucumber.js";
52
37
  const configFilePath = path.isAbsolute(configFileInput)
53
38
  ? configFileInput
54
39
  : path.resolve(process.cwd(), configFileInput);
@@ -71,6 +56,8 @@ if (fs.existsSync(configFilePath)) {
71
56
  const cleanReports =
72
57
  typeof argv.cleanReports === "boolean"
73
58
  ? argv.cleanReports
59
+ : typeof argv.clean === "boolean"
60
+ ? argv.clean
74
61
  : process.env.CLEAN_REPORTS
75
62
  ? process.env.CLEAN_REPORTS === "true"
76
63
  : configOptions.cleanReports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -62,17 +62,15 @@
62
62
  "@cucumber/cucumber": "*",
63
63
  "k6": "*"
64
64
  },
65
- "devDependencies": {
65
+ "dependencies": {
66
66
  "@babel/cli": "^7.27.2",
67
67
  "@babel/core": "^7.27.4",
68
68
  "@babel/preset-env": "^7.27.2",
69
+ "@babel/register": "^7.27.1",
69
70
  "@faker-js/faker": "^9.8.0",
70
71
  "@types/k6": "^1.0.2",
72
+ "commander": "^14.0.0",
71
73
  "dotenv": "^16.5.0",
72
- "html-minifier-terser": "^7.2.0",
73
- "yargs": "^18.0.0"
74
- },
75
- "dependencies": {
76
- "@babel/register": "^7.27.1"
74
+ "html-minifier-terser": "^7.2.0"
77
75
  }
78
76
  }