artes 1.0.55 → 1.0.57

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
@@ -49,9 +49,10 @@ npx artes [options]
49
49
  | 🏗️ `-c, --create` | Create an example project with Artes | `artes -c` or `artes --create` |
50
50
  | ✅ `-y, --yes` | Skip the confirmation prompt when creating an example project | `artes -c -y` or `artes --create --yes` |
51
51
  | 📊 `-r, --report` | Run tests and generate Allure report | `artes -r` or `artes --report` |
52
- | 📁 `--features` | Specify one or more feature files to run (comma-separated) | `artes --features 'Alma, Banan'` |
53
- | 🔖 `--tags` | Run tests with specified Cucumber tags | `artes --tags "@smoke or @wip"` |
54
-
52
+ | 📁 `--features` | Specify one or more feature files to run (comma-separated) | `artes --features 'Alma, Banan'` |
53
+ | 🔖 `--tags` | Run tests with specified Cucumber tags | `artes --tags "@smoke or @wip"` |
54
+ | 🌐 `--env` | Set the environment for the test run | `artes --env "dev"` |
55
+ | 🕶️ `--headless` | Run browser in headless mode | `artes --headless` |
55
56
 
56
57
  \*\* To just run the tests: <br>
57
58
  Globally: artes <br>
@@ -87,6 +87,10 @@ module.exports = {
87
87
  artesConfig?.maximizeScreen !== undefined
88
88
  ? artesConfig.maximizeScreen
89
89
  : true,
90
- headless: artesConfig?.headless !== undefined ? artesConfig.headless : true,
90
+ headless: process.env.MODE
91
+ ? JSON.parse(process.env.MODE)
92
+ : artesConfig?.headless !== undefined
93
+ ? artesConfig.headless
94
+ : true,
91
95
  },
92
96
  };
package/executer.js CHANGED
@@ -21,6 +21,7 @@ const flags = {
21
21
  features: args.includes("--features"),
22
22
  tags: args.includes("--tags"),
23
23
  env: args.includes("--env"),
24
+ headless: args.includes("--headless"),
24
25
  };
25
26
 
26
27
  function main() {
@@ -46,11 +47,11 @@ function main() {
46
47
  // }
47
48
 
48
49
  if (flags.report) {
49
- runTests(flags.report, flags.tags, flags.features, flags.env);
50
+ runTests(args, flags);
50
51
  generateReport();
51
52
  cleanUp();
52
53
  } else {
53
- runTests(flags.report, flags.tags, flags.features, flags.env);
54
+ runTests(args, flags);
54
55
  cleanUp();
55
56
  }
56
57
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.0.55",
4
- "description": "The package provide step definitions and user writes feature files, and the package handles automation, with optional POM files and custom step definitions.",
3
+ "version": "1.0.57",
4
+ "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "cucumber-js --config=cucumber.config.js",
@@ -30,6 +30,12 @@ function showHelp() {
30
30
 
31
31
  🔖 --tags Run tests with specified Cucumber tags
32
32
  Usage: artes --tags "@smoke and not @wip"
33
+
34
+ 🌐 --env Set environment for the test run
35
+ Usage: artes --env "dev"
36
+
37
+ 🕶️ --headless Run browser in headless mode
38
+ Usage: artes --headless
33
39
  `);
34
40
  }
35
41
 
@@ -39,7 +39,8 @@ function createProject(createYes) {
39
39
  headless: false, // Set to true for headless browser mode
40
40
 
41
41
  // Configuration options:
42
- // baseURL: "", // string - Base URL for API tests
42
+ // env: "", // string - Environment name for tests
43
+ // baseURL: "", // string - Base URL for API tests
43
44
  // paths: [], // string[] - Paths to feature files
44
45
  // steps: "", // string - Step definitions files
45
46
  // pomPath: "", // string - Path to POM files
@@ -2,35 +2,39 @@ const { spawnSync } = require("child_process");
2
2
  const { moduleConfig } = require("../imports/commons");
3
3
  const path = require("path");
4
4
 
5
- function runTests(flagReport, flagTags, flagFeatures, flagEnv) {
6
- const args = process.argv.slice(2);
7
-
5
+ function runTests(args, flags) {
8
6
  const env = args[args.indexOf("--env") + 1];
9
7
 
10
8
  const featureFiles = args[args.indexOf("--features") + 1];
11
9
  const features =
12
- flagFeatures &&
10
+ flags.features &&
13
11
  featureFiles
14
12
  .split(",")
15
13
  .map((f) => path.join(moduleConfig.featuresPath, `${f.trim()}.feature`));
16
14
 
17
15
  const tags = args[args.indexOf("--tags") + 1];
18
16
 
19
- flagEnv && console.log("Running env:", env);
20
- flagEnv ? (process.env.ENV = JSON.stringify(env)) : "";
17
+ const headless = args.includes("--headless");
18
+
19
+ flags.env && console.log("Running env:", env);
20
+ flags.env ? (process.env.ENV = JSON.stringify(env)) : "";
21
21
 
22
- flagReport
22
+ flags.report
23
23
  ? (process.env.REPORT_FORMAT = JSON.stringify([
24
24
  "rerun:@rerun.txt",
25
25
  "allure-cucumberjs/reporter",
26
26
  ]))
27
27
  : "";
28
28
 
29
- flagTags && console.log("Running tags:", tags);
30
- flagTags ? (process.env.RUN_TAGS = JSON.stringify(tags)) : "";
29
+ flags.tags && console.log("Running tags:", tags);
30
+ flags.tags ? (process.env.RUN_TAGS = JSON.stringify(tags)) : "";
31
+
32
+ flags.features && console.log("Running features:", features);
33
+ flags.features ? (process.env.FEATURES = JSON.stringify(features)) : "";
31
34
 
32
- flagFeatures && console.log("Running features:", features);
33
- flagFeatures ? (process.env.FEATURES = JSON.stringify(features)) : "";
35
+ flags.headless &&
36
+ console.log("Running mode:", flags.headless ? "headless" : "headed");
37
+ flags.headless ? (process.env.MODE = JSON.stringify(true)) : false;
34
38
 
35
39
  try {
36
40
  console.log("🧪 Running tests...");
@@ -80,33 +80,43 @@ const api = {
80
80
  const res = await context.request.get(resolvedURL, {
81
81
  headers: payloadJSON ? payloadJSON.headers : {},
82
82
  });
83
- const header = await res.headers();
84
- const body = await res.json();
85
83
 
86
- const response = {
87
- url: res.url(),
88
- response: res,
89
- responseHeaders: header,
90
- responseBody: body,
91
- };
84
+ try {
85
+ const header = await res.headers();
86
+ const body = await res.json();
87
+
88
+ const response = {
89
+ url: res.url(),
90
+ response: res,
91
+ responseHeaders: header,
92
+ responseBody: body,
93
+ };
92
94
 
93
- context.response = response;
95
+ context.response = response;
96
+ } catch (error) {
97
+ throw new Error(`Error processing response: ${error.message}`);
98
+ }
94
99
  },
95
100
  head: async (url) => {
96
101
  const URL = await selector(url);
97
102
  const resolvedURL = await resolveVariable(URL);
98
103
 
99
104
  const res = await context.request.head(resolvedURL);
100
- const header = await res.headers();
101
105
 
102
- const response = {
103
- url: res.url(),
104
- response: res,
105
- responseHeaders: header,
106
- responseBody: body,
107
- };
106
+ try {
107
+ const header = await res.headers();
108
+
109
+ const response = {
110
+ url: res.url(),
111
+ response: res,
112
+ responseHeaders: header,
113
+ responseBody: body,
114
+ };
108
115
 
109
- context.response = response;
116
+ context.response = response;
117
+ } catch (error) {
118
+ throw new Error(`Error processing response: ${error.message}`);
119
+ }
110
120
  },
111
121
  post: async (url, payload, bodyType) => {
112
122
  const URL = await selector(url);
@@ -136,19 +146,22 @@ const api = {
136
146
 
137
147
  const res = await context.request.post(resolvedURL, requestBody);
138
148
 
139
- const header = await res.headers();
140
- const body = await res.json();
141
-
142
- const response = {
143
- url: res.url(),
144
- requestHeaders: payloadJSON.headers,
145
- requestBody: payloadJSON.body,
146
- response: res,
147
- responseHeaders: header,
148
- responseBody: body,
149
- };
150
-
151
- context.response = response;
149
+ try {
150
+ const header = await res.headers();
151
+ const body = await res.json();
152
+
153
+ const response = {
154
+ url: res.url(),
155
+ requestHeaders: payloadJSON.headers,
156
+ requestBody: payloadJSON.body,
157
+ response: res,
158
+ responseHeaders: header,
159
+ responseBody: body,
160
+ };
161
+ context.response = response;
162
+ } catch (error) {
163
+ throw new Error(`Error processing response: ${error.message}`);
164
+ }
152
165
  },
153
166
  put: async (url, payload, bodyType) => {
154
167
  const URL = await selector(url);
@@ -178,19 +191,22 @@ const api = {
178
191
 
179
192
  const res = await context.request.put(resolvedURL, requestBody);
180
193
 
181
- const header = await res.headers();
182
- const body = await res.json();
183
-
184
- const response = {
185
- url: res.url(),
186
- requestHeaders: payloadJSON.headers,
187
- requestBody: payloadJSON.body,
188
- response: res,
189
- responseHeaders: header,
190
- responseBody: body,
191
- };
192
-
193
- context.response = response;
194
+ try {
195
+ const header = await res.headers();
196
+ const body = await res.json();
197
+
198
+ const response = {
199
+ url: res.url(),
200
+ requestHeaders: payloadJSON.headers,
201
+ requestBody: payloadJSON.body,
202
+ response: res,
203
+ responseHeaders: header,
204
+ responseBody: body,
205
+ };
206
+ context.response = response;
207
+ } catch (error) {
208
+ throw new Error(`Error processing response: ${error.message}`);
209
+ }
194
210
  },
195
211
  patch: async (url, payload, bodyType) => {
196
212
  const URL = await selector(url);
@@ -220,19 +236,22 @@ const api = {
220
236
 
221
237
  const res = await context.request.patch(resolvedURL, requestBody);
222
238
 
223
- const header = await res.headers();
224
- const body = await res.json();
225
-
226
- const response = {
227
- url: res.url(),
228
- requestHeaders: payloadJSON.headers,
229
- requestBody: payloadJSON.body,
230
- response: res,
231
- responseHeaders: header,
232
- responseBody: body,
233
- };
234
-
235
- context.response = response;
239
+ try {
240
+ const header = await res.headers();
241
+ const body = await res.json();
242
+
243
+ const response = {
244
+ url: res.url(),
245
+ requestHeaders: payloadJSON.headers,
246
+ requestBody: payloadJSON.body,
247
+ response: res,
248
+ responseHeaders: header,
249
+ responseBody: body,
250
+ };
251
+ context.response = response;
252
+ } catch (error) {
253
+ throw new Error(`Error processing response: ${error.message}`);
254
+ }
236
255
  },
237
256
  delete: async (url, payload) => {
238
257
  const URL = await selector(url);
@@ -245,17 +264,21 @@ const api = {
245
264
  headers: payloadJSON.headers,
246
265
  });
247
266
 
248
- const header = await res.headers();
249
- const body = await res.json();
250
-
251
- const response = {
252
- url: res.url(),
253
- response: res,
254
- responseHeaders: header,
255
- responseBody: body,
256
- };
267
+ try {
268
+ const header = await res.headers();
269
+ const body = await res.json();
270
+
271
+ const response = {
272
+ url: res.url(),
273
+ response: res,
274
+ responseHeaders: header,
275
+ responseBody: body,
276
+ };
257
277
 
258
- context.response = response;
278
+ context.response = response;
279
+ } catch (error) {
280
+ throw new Error(`Error processing response: ${error.message}`);
281
+ }
259
282
  },
260
283
  vars: () => {
261
284
  return context.vars;