k6-cucumber-steps 1.0.25 → 1.0.27

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,4 +1,4 @@
1
- name: Node.js Package Release
1
+ name: build
2
2
 
3
3
  on:
4
4
  push:
@@ -7,7 +7,8 @@ on:
7
7
  jobs:
8
8
  release:
9
9
  runs-on: ubuntu-latest
10
-
10
+ permissions:
11
+ contents: write
11
12
  strategy:
12
13
  matrix:
13
14
  node-version: [lts/*]
@@ -19,7 +20,7 @@ jobs:
19
20
  with:
20
21
  node-version: ${{ matrix.node-version }}
21
22
  cache: "npm"
22
- registry-url: "https://registry.npmjs.org" # Add this line
23
+ registry-url: "https://registry.npmjs.org"
23
24
  - name: Install Dependencies
24
25
  run: npm install
25
26
  - name: Configure Git for Commit
@@ -32,6 +33,10 @@ jobs:
32
33
  run: git commit -m "chore:Automated changes before versioning" || echo "No changes to commit"
33
34
  - name: Set new version as patch and create commit
34
35
  run: npm version patch
36
+ - name: Check new version
37
+ run: echo "New version is $(npm pkg get version)"
38
+ - name: Push changes
39
+ run: git push --follow-tags
35
40
  - name: Publish to npm
36
41
  run: npm publish
37
42
  env:
package/README.md CHANGED
@@ -7,11 +7,10 @@
7
7
  [![npm version](https://img.shields.io/npm/v/k6-cucumber-steps.svg)](https://www.npmjs.com/package/k6-cucumber-steps)
8
8
  [![npm downloads](https://img.shields.io/npm/dt/k6-cucumber-steps.svg)](https://www.npmjs.com/package/k6-cucumber-steps)
9
9
  [![license](https://img.shields.io/npm/l/k6-cucumber-steps)](https://github.com/qaPaschalE/k6-cucumber-steps/blob/main/LICENSE)
10
-
11
10
  [![Cucumber](https://img.shields.io/badge/built%20with-Cucumber-3178c6.svg)](https://cucumber.io/)
12
11
  [![Node.js](https://img.shields.io/badge/node-%3E=18-green.svg)](https://nodejs.org/)
13
12
  [![Sponsor](https://img.shields.io/github/sponsors/qaPaschalE?style=social)](https://github.com/sponsors/qaPaschalE)
14
- [![Build Status](https://github.com/qap/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
+ [![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)
15
14
 
16
15
  Run [k6](https://k6.io/) performance/load tests using [Cucumber](https://cucumber.io/) BDD syntax with ease.
17
16
 
@@ -8,15 +8,33 @@ const packageJson = require("../../package.json"); // Access package version
8
8
  * Generates a temporary k6 script file.
9
9
  * @param {string} scriptContent - The content of the k6 script.
10
10
  * @param {string} [scriptType='load'] - Type of script (e.g., 'load').
11
+ * @param {boolean} [overwrite=false] - Whether to overwrite the report file.
11
12
  * @returns {Promise<string>} - Path to the generated k6 script file.
12
13
  */
13
- const generateK6Script = async (scriptContent, scriptType = "load") => {
14
+ const generateK6Script = async (
15
+ scriptContent,
16
+ scriptType = "load",
17
+ overwrite = false
18
+ ) => {
14
19
  const tempDir = path.resolve(__dirname, "../../temp");
15
20
  const scriptName = `${scriptType}_script_${uuidv4()}.js`;
16
21
  const scriptPath = path.join(tempDir, scriptName);
17
- await fs.mkdir(tempDir, { recursive: true }); // Ensure temp directory exists
18
- await fs.writeFile(scriptPath, scriptContent, "utf8");
19
- return scriptPath;
22
+
23
+ try {
24
+ await fs.mkdir(tempDir, { recursive: true }); // Ensure temp directory exists
25
+
26
+ // Write the script content based on the overwrite flag
27
+ if (overwrite) {
28
+ await fs.writeFile(scriptPath, scriptContent, { flag: "w" }); // Overwrite mode
29
+ } else {
30
+ await fs.appendFile(scriptPath, scriptContent); // Append mode
31
+ }
32
+
33
+ return scriptPath;
34
+ } catch (error) {
35
+ console.error(`Error generating k6 script: ${error.message}`);
36
+ throw error;
37
+ }
20
38
  };
21
39
 
22
40
  /**
@@ -29,9 +47,10 @@ const delay = (ms) => new Promise((res) => setTimeout(res, ms));
29
47
  /**
30
48
  * Runs the k6 script with custom branding.
31
49
  * @param {string} scriptPath - Path to the k6 script file.
50
+ * @param {boolean} [overwrite=false] - Whether to overwrite the report file.
32
51
  * @returns {Promise<string>} - Standard output from k6 execution.
33
52
  */
34
- const runK6Script = async (scriptPath) => {
53
+ const runK6Script = async (scriptPath, overwrite = false) => {
35
54
  // ANSI escape codes for colors
36
55
  const chalkGreen = "\x1b[38;2;0;255;0m"; // Green
37
56
  const chalkYellow = "\x1b[38;2;255;255;0m"; // Yellow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {