artes 1.0.56 → 1.0.58
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 +4 -3
- package/cucumber.config.js +5 -1
- package/executer.js +3 -2
- package/package.json +2 -2
- package/src/helper/executers/helper.js +6 -0
- package/src/helper/executers/projectCreator.js +1 -1
- package/src/helper/executers/testRunner.js +14 -11
- package/src/helper/stepFunctions/APIActions.js +36 -34
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>
|
package/cucumber.config.js
CHANGED
|
@@ -87,6 +87,10 @@ module.exports = {
|
|
|
87
87
|
artesConfig?.maximizeScreen !== undefined
|
|
88
88
|
? artesConfig.maximizeScreen
|
|
89
89
|
: true,
|
|
90
|
-
headless:
|
|
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(
|
|
50
|
+
runTests(args, flags);
|
|
50
51
|
generateReport();
|
|
51
52
|
cleanUp();
|
|
52
53
|
} else {
|
|
53
|
-
runTests(
|
|
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.
|
|
4
|
-
"description": "The
|
|
3
|
+
"version": "1.0.58",
|
|
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
|
|
|
@@ -128,7 +128,7 @@ await context.page.goto("https://www.saucedemo.com/");
|
|
|
128
128
|
"tests/steps/*.{ts,js}",
|
|
129
129
|
"node_modules/artes/src/stepDefinitions/*.{ts,js}",
|
|
130
130
|
],
|
|
131
|
-
"cucumber.features": ["tests/features
|
|
131
|
+
"cucumber.features": ["tests/features/**/*.feature"],
|
|
132
132
|
"cucumberautocomplete.syncfeatures": true,
|
|
133
133
|
"cucumberautocomplete.strictGherkinCompletion": true,
|
|
134
134
|
});
|
|
@@ -2,35 +2,38 @@ const { spawnSync } = require("child_process");
|
|
|
2
2
|
const { moduleConfig } = require("../imports/commons");
|
|
3
3
|
const path = require("path");
|
|
4
4
|
|
|
5
|
-
function runTests(
|
|
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
|
-
|
|
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
|
-
|
|
20
|
-
|
|
17
|
+
|
|
18
|
+
flags.env && console.log("Running env:", env);
|
|
19
|
+
flags.env ? (process.env.ENV = JSON.stringify(env)) : "";
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
flags.report
|
|
23
22
|
? (process.env.REPORT_FORMAT = JSON.stringify([
|
|
24
23
|
"rerun:@rerun.txt",
|
|
25
24
|
"allure-cucumberjs/reporter",
|
|
26
25
|
]))
|
|
27
26
|
: "";
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
flags.tags && console.log("Running tags:", tags);
|
|
29
|
+
flags.tags ? (process.env.RUN_TAGS = JSON.stringify(tags)) : "";
|
|
30
|
+
|
|
31
|
+
flags.features && console.log("Running features:", features);
|
|
32
|
+
flags.features ? (process.env.FEATURES = JSON.stringify(features)) : "";
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
flags.headless &&
|
|
35
|
+
console.log("Running mode:", flags.headless ? "headless" : "headed");
|
|
36
|
+
flags.headless ? (process.env.MODE = JSON.stringify(true)) : false;
|
|
34
37
|
|
|
35
38
|
try {
|
|
36
39
|
console.log("🧪 Running tests...");
|
|
@@ -30,7 +30,7 @@ function processForm(key, value) {
|
|
|
30
30
|
typeof value.data === "object"
|
|
31
31
|
? JSON.stringify(value.data)
|
|
32
32
|
: String(value.data);
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
formData[key] = {
|
|
35
35
|
name: value.filename || key,
|
|
36
36
|
mimeType: value.contentType,
|
|
@@ -80,20 +80,20 @@ const api = {
|
|
|
80
80
|
const res = await context.request.get(resolvedURL, {
|
|
81
81
|
headers: payloadJSON ? payloadJSON.headers : {},
|
|
82
82
|
});
|
|
83
|
-
|
|
84
|
-
try{
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
85
|
const header = await res.headers();
|
|
86
86
|
const body = await res.json();
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
const response = {
|
|
89
89
|
url: res.url(),
|
|
90
90
|
response: res,
|
|
91
91
|
responseHeaders: header,
|
|
92
92
|
responseBody: body,
|
|
93
93
|
};
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
context.response = response;
|
|
96
|
-
}catch(error) {
|
|
96
|
+
} catch (error) {
|
|
97
97
|
throw new Error(`Error processing response: ${error.message}`);
|
|
98
98
|
}
|
|
99
99
|
},
|
|
@@ -102,19 +102,19 @@ const api = {
|
|
|
102
102
|
const resolvedURL = await resolveVariable(URL);
|
|
103
103
|
|
|
104
104
|
const res = await context.request.head(resolvedURL);
|
|
105
|
-
|
|
106
|
-
try{
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
107
|
const header = await res.headers();
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
const response = {
|
|
110
110
|
url: res.url(),
|
|
111
111
|
response: res,
|
|
112
112
|
responseHeaders: header,
|
|
113
113
|
responseBody: body,
|
|
114
114
|
};
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
context.response = response;
|
|
117
|
-
}catch(error) {
|
|
117
|
+
} catch (error) {
|
|
118
118
|
throw new Error(`Error processing response: ${error.message}`);
|
|
119
119
|
}
|
|
120
120
|
},
|
|
@@ -129,12 +129,14 @@ const api = {
|
|
|
129
129
|
|
|
130
130
|
switch (bodyType) {
|
|
131
131
|
case "multipart":
|
|
132
|
+
let combinedFormData = {};
|
|
132
133
|
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
133
|
-
|
|
134
|
+
const formData = processForm(key, value);
|
|
135
|
+
Object.assign(combinedFormData, formData);
|
|
134
136
|
}
|
|
135
137
|
requestBody = {
|
|
136
138
|
headers: payloadJSON.headers,
|
|
137
|
-
multipart:
|
|
139
|
+
multipart: combinedFormData,
|
|
138
140
|
};
|
|
139
141
|
break;
|
|
140
142
|
default:
|
|
@@ -146,10 +148,10 @@ const api = {
|
|
|
146
148
|
|
|
147
149
|
const res = await context.request.post(resolvedURL, requestBody);
|
|
148
150
|
|
|
149
|
-
try{
|
|
151
|
+
try {
|
|
150
152
|
const header = await res.headers();
|
|
151
153
|
const body = await res.json();
|
|
152
|
-
|
|
154
|
+
|
|
153
155
|
const response = {
|
|
154
156
|
url: res.url(),
|
|
155
157
|
requestHeaders: payloadJSON.headers,
|
|
@@ -159,11 +161,9 @@ const api = {
|
|
|
159
161
|
responseBody: body,
|
|
160
162
|
};
|
|
161
163
|
context.response = response;
|
|
162
|
-
}catch(error) {
|
|
164
|
+
} catch (error) {
|
|
163
165
|
throw new Error(`Error processing response: ${error.message}`);
|
|
164
166
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
167
|
},
|
|
168
168
|
put: async (url, payload, bodyType) => {
|
|
169
169
|
const URL = await selector(url);
|
|
@@ -176,12 +176,14 @@ const api = {
|
|
|
176
176
|
|
|
177
177
|
switch (bodyType) {
|
|
178
178
|
case "multipart":
|
|
179
|
+
let combinedFormData = {};
|
|
179
180
|
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
180
|
-
|
|
181
|
+
const formData = processForm(key, value);
|
|
182
|
+
Object.assign(combinedFormData, formData);
|
|
181
183
|
}
|
|
182
184
|
requestBody = {
|
|
183
185
|
headers: payloadJSON.headers,
|
|
184
|
-
multipart:
|
|
186
|
+
multipart: combinedFormData,
|
|
185
187
|
};
|
|
186
188
|
break;
|
|
187
189
|
default:
|
|
@@ -193,10 +195,10 @@ const api = {
|
|
|
193
195
|
|
|
194
196
|
const res = await context.request.put(resolvedURL, requestBody);
|
|
195
197
|
|
|
196
|
-
try{
|
|
198
|
+
try {
|
|
197
199
|
const header = await res.headers();
|
|
198
200
|
const body = await res.json();
|
|
199
|
-
|
|
201
|
+
|
|
200
202
|
const response = {
|
|
201
203
|
url: res.url(),
|
|
202
204
|
requestHeaders: payloadJSON.headers,
|
|
@@ -206,7 +208,7 @@ const api = {
|
|
|
206
208
|
responseBody: body,
|
|
207
209
|
};
|
|
208
210
|
context.response = response;
|
|
209
|
-
}catch(error) {
|
|
211
|
+
} catch (error) {
|
|
210
212
|
throw new Error(`Error processing response: ${error.message}`);
|
|
211
213
|
}
|
|
212
214
|
},
|
|
@@ -221,12 +223,14 @@ const api = {
|
|
|
221
223
|
|
|
222
224
|
switch (bodyType) {
|
|
223
225
|
case "multipart":
|
|
226
|
+
let combinedFormData = {};
|
|
224
227
|
for (const [key, value] of Object.entries(payloadJSON.body)) {
|
|
225
|
-
|
|
228
|
+
const formData = processForm(key, value);
|
|
229
|
+
Object.assign(combinedFormData, formData);
|
|
226
230
|
}
|
|
227
231
|
requestBody = {
|
|
228
232
|
headers: payloadJSON.headers,
|
|
229
|
-
multipart:
|
|
233
|
+
multipart: combinedFormData,
|
|
230
234
|
};
|
|
231
235
|
break;
|
|
232
236
|
default:
|
|
@@ -238,10 +242,10 @@ const api = {
|
|
|
238
242
|
|
|
239
243
|
const res = await context.request.patch(resolvedURL, requestBody);
|
|
240
244
|
|
|
241
|
-
try{
|
|
245
|
+
try {
|
|
242
246
|
const header = await res.headers();
|
|
243
247
|
const body = await res.json();
|
|
244
|
-
|
|
248
|
+
|
|
245
249
|
const response = {
|
|
246
250
|
url: res.url(),
|
|
247
251
|
requestHeaders: payloadJSON.headers,
|
|
@@ -251,7 +255,7 @@ const api = {
|
|
|
251
255
|
responseBody: body,
|
|
252
256
|
};
|
|
253
257
|
context.response = response;
|
|
254
|
-
}catch(error) {
|
|
258
|
+
} catch (error) {
|
|
255
259
|
throw new Error(`Error processing response: ${error.message}`);
|
|
256
260
|
}
|
|
257
261
|
},
|
|
@@ -266,23 +270,21 @@ const api = {
|
|
|
266
270
|
headers: payloadJSON.headers,
|
|
267
271
|
});
|
|
268
272
|
|
|
269
|
-
|
|
270
|
-
try{
|
|
273
|
+
try {
|
|
271
274
|
const header = await res.headers();
|
|
272
275
|
const body = await res.json();
|
|
273
|
-
|
|
276
|
+
|
|
274
277
|
const response = {
|
|
275
278
|
url: res.url(),
|
|
276
279
|
response: res,
|
|
277
280
|
responseHeaders: header,
|
|
278
281
|
responseBody: body,
|
|
279
282
|
};
|
|
280
|
-
|
|
283
|
+
|
|
281
284
|
context.response = response;
|
|
282
|
-
}catch(error) {
|
|
285
|
+
} catch (error) {
|
|
283
286
|
throw new Error(`Error processing response: ${error.message}`);
|
|
284
287
|
}
|
|
285
|
-
|
|
286
288
|
},
|
|
287
289
|
vars: () => {
|
|
288
290
|
return context.vars;
|