k6-cucumber-steps 1.0.36 → 1.0.38

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
@@ -150,6 +150,7 @@ npx k6-cucumber-steps run --configFile cucumber.prod.js
150
150
 
151
151
  ```env
152
152
  BASE_URL=[https://api.example.com](https://api.example.com)
153
+ API_BASE_URL=[https://api.example.com](https://api.example.com)
153
154
  API_KEY=your_api_key
154
155
  BEARER_TOKEN=your_bearer_token
155
156
  BASIC_USER=your_basic_user
@@ -1,5 +1,6 @@
1
1
  module.exports = function buildK6Script(config) {
2
2
  const { method, endpoints, endpoint, body, headers, options } = config;
3
+
3
4
  // Ensure at least one of `endpoints` or `endpoint` is defined
4
5
  if (!endpoints?.length && !endpoint) {
5
6
  throw new Error(
@@ -7,10 +8,12 @@ module.exports = function buildK6Script(config) {
7
8
  );
8
9
  }
9
10
 
10
- // Get BASE_URL from environment variables
11
- const BASE_URL = process.env.BASE_URL;
11
+ // Prefer API_BASE_URL, fallback to BASE_URL
12
+ const BASE_URL = process.env.API_BASE_URL || process.env.BASE_URL;
12
13
  if (!BASE_URL) {
13
- throw new Error("BASE_URL is not defined in the environment variables.");
14
+ throw new Error(
15
+ "Neither API_BASE_URL nor BASE_URL is defined in the environment variables."
16
+ );
14
17
  }
15
18
 
16
19
  // Resolve relative endpoints by prepending BASE_URL
@@ -47,7 +50,7 @@ export default function () {
47
50
  .join("\n")
48
51
  : `
49
52
  const resolvedUrl = "${resolveEndpoint(endpoint)}";
50
- \ const res = http.request("${method}", resolvedUrl, ${
53
+ const res = http.request("${method}", resolvedUrl, ${
51
54
  method === "GET" || method === "DELETE"
52
55
  ? "null"
53
56
  : JSON.stringify(body)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-cucumber-steps",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -66,6 +66,7 @@
66
66
  "@babel/register": "latest",
67
67
  "@cucumber/cucumber": "latest",
68
68
  "@faker-js/faker": "latest",
69
+ "axios": "^1.9.0",
69
70
  "dotenv": "latest",
70
71
  "yargs": "latest"
71
72
  }