artes 1.1.45 → 1.1.47

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.
@@ -30,6 +30,21 @@ const finalFormats = [
30
30
  ]),
31
31
  ];
32
32
 
33
+ function resolveEnv(artesConfig) {
34
+ if (typeof artesConfig.baseURL === "object" && artesConfig.baseURL !== null) {
35
+ if (process.env.ENV && artesConfig.baseURL.hasOwnProperty(process.env.ENV.trim())) {
36
+ return process.env.ENV.trim();
37
+ } else if (artesConfig.env && artesConfig.baseURL.hasOwnProperty(artesConfig.env.trim())) {
38
+ return artesConfig.env.trim();
39
+ } else {
40
+ return Object.keys(artesConfig.baseURL)[0];
41
+ }
42
+ }
43
+
44
+ return process.env.ENV || artesConfig.env || "";
45
+ }
46
+ const env = resolveEnv(artesConfig);
47
+
33
48
  module.exports = {
34
49
  default: {
35
50
  // File paths and patterns
@@ -116,17 +131,7 @@ module.exports = {
116
131
  // World parameters
117
132
  worldParameters: artesConfig.worldParameters || {}, // Custom world parameters
118
133
  },
119
- env: (typeof artesConfig.baseURL === "object" && artesConfig.baseURL !== null
120
- ? (
121
- process.env.ENV && artesConfig.baseURL.hasOwnProperty(process.env.ENV.trim())
122
- ? process.env.ENV.trim()
123
- : (
124
- artesConfig.env && artesConfig.baseURL.hasOwnProperty(artesConfig.env.trim())
125
- ? artesConfig.env.trim()
126
- : Object.keys(artesConfig.baseURL)[0]
127
- )
128
- )
129
- : (process.env.ENV || artesConfig.env || "")),
134
+ env: env,
130
135
  baseURL: process.env.BASE_URL
131
136
  ? JSON.parse(process.env.BASE_URL)
132
137
  : artesConfig?.baseURL
package/executer.js CHANGED
@@ -55,22 +55,8 @@ const height = args[args.indexOf("--height") + 1];
55
55
  const timeout = args[args.indexOf("--timeout") + 1];
56
56
  const slowMo = args[args.indexOf("--slowMo") + 1];
57
57
 
58
- if (flags.env) {
59
- const envCandidate = env.trim();
60
- if (typeof artesConfig.baseURL === "object" && artesConfig.baseURL !== null) {
61
- if (artesConfig.baseURL.hasOwnProperty(envCandidate)) {
62
- process.env.ENV = JSON.stringify(envCandidate);
63
- console.log("Running env:", envCandidate);
64
- } else {
65
- const firstKey = Object.keys(artesConfig.baseURL)[0];
66
- process.env.ENV = JSON.stringify(firstKey);
67
- console.log(`Env "${envCandidate}" not found, falling back to:`, firstKey);
68
- }
69
- } else {
70
- process.env.ENV = JSON.stringify(envCandidate);
71
- console.log("Running env:", envCandidate);
72
- }
73
- }
58
+
59
+ flags.env ? (process.env.ENV = env) : ""
74
60
 
75
61
  flags.reportWithTrace ||
76
62
  artesConfig.reportWithTrace ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,12 +8,7 @@ const invokeBrowser = async () => {
8
8
 
9
9
  if (typeof cucumberConfig.baseURL === "object") {
10
10
  const env = (cucumberConfig.env || "").trim();
11
- if (env && cucumberConfig.baseURL.hasOwnProperty(env)) {
12
11
  baseURL = cucumberConfig.baseURL[env];
13
- } else {
14
- const firstKey = Object.keys(cucumberConfig.baseURL)[0];
15
- baseURL = cucumberConfig.baseURL[firstKey];
16
- }
17
12
  } else {
18
13
  baseURL = cucumberConfig.baseURL;
19
14
  }
@@ -5,12 +5,7 @@ let baseURL = "";
5
5
 
6
6
  if (typeof cucumberConfig.baseURL === "object") {
7
7
  const env = (cucumberConfig.env || "").trim();
8
- if (env && cucumberConfig.baseURL.hasOwnProperty(env)) {
9
8
  baseURL = cucumberConfig.baseURL[env];
10
- } else {
11
- const firstKey = Object.keys(cucumberConfig.baseURL)[0];
12
- baseURL = cucumberConfig.baseURL[firstKey];
13
- }
14
9
  } else {
15
10
  baseURL = cucumberConfig.baseURL;
16
11
  }
@@ -134,17 +134,42 @@ function saveVar(value, customName, path) {
134
134
  }
135
135
 
136
136
  function resolveVariable(template) {
137
- if (typeof template !== "string") return template;
138
- return template.replace(/{{\s*(\w+)\s*}}/g, (_, varName) => {
139
- let value = context.vars[varName];
140
- if (typeof value === "string") {
141
- value = value
142
- .replace(/\n/g, "\\n")
143
- .replace(/\r/g, "\\r")
144
- .replace(/\t/g, "\\t");
137
+ if (typeof template === "string") {
138
+ return template.replace(/{{\s*(\w+)\s*}}/g, (_, varName) => {
139
+ let value = context.vars[varName];
140
+
141
+ if (value !== undefined) {
142
+ if (typeof value !== "string") {
143
+ try {
144
+ value = JSON.stringify(value);
145
+ } catch {
146
+ value = String(value);
147
+ }
148
+ }
149
+
150
+ return value
151
+ .replace(/\n/g, "\\n")
152
+ .replace(/\r/g, "\\r")
153
+ .replace(/\t/g, "\\t");
154
+ }
155
+
156
+ return `{{${varName}}}`;
157
+ });
158
+ }
159
+
160
+ if (Array.isArray(template)) {
161
+ return template.map((item) => resolveVariable(item));
162
+ }
163
+
164
+ if (template && typeof template === "object") {
165
+ const result = {};
166
+ for (const key in template) {
167
+ result[key] = resolveVariable(template[key]);
145
168
  }
146
- return value !== undefined ? value : `{{${varName}}}`;
147
- });
169
+ return result;
170
+ }
171
+
172
+ return template;
148
173
  }
149
174
 
150
175
  module.exports = {
@@ -1,6 +1,7 @@
1
1
  const { addElements } = require("./elementController");
2
2
  const cucumberConfig = require("../../../cucumber.config");
3
3
  const fs = require("fs");
4
+
4
5
  function pomCollector() {
5
6
  if (fs.existsSync(cucumberConfig.default.pomPath)) {
6
7
  fs.readdir(`${cucumberConfig.default.pomPath}`, (err, files) => {
@@ -12,6 +12,7 @@ const browser = {
12
12
  }
13
13
 
14
14
  cookieData = Array.isArray(cookieData) ? cookieData : [cookieData];
15
+
15
16
  await context.browserContext.addCookies(cookieData);
16
17
  },
17
18
  };
@@ -190,6 +190,21 @@ When('User types random fullname in {string}', async (input) => {
190
190
  await element(input).fill(`${randomFirstName} ${randomLastName}`)
191
191
  })
192
192
 
193
+ When('User types random first name in {string}', async (input) => {
194
+ const randomFirstName = await random.person.firstName()
195
+ await element(input).fill(randomFirstName)
196
+ })
197
+
198
+ When('User types random last name in {string}', async (input) => {
199
+ const randomLastName = await random.person.lastName()
200
+ await element(input).fill(randomLastName)
201
+ })
202
+
203
+ When('User types random middle name in {string}', async (input) => {
204
+ const randomMiddleName = await random.person.middleName()
205
+ await element(input).fill(randomMiddleName)
206
+ })
207
+
193
208
  When('User types random date between {int} and {int} in {string}', async (fromYear, toYear, input) => {
194
209
  const year = Math.floor(Math.random() * (toYear - fromYear + 1)) + fromYear
195
210
  const month = Math.floor(Math.random() * 12) + 1