artes 1.7.4 → 1.7.6

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.
Files changed (48) hide show
  1. package/README.md +781 -779
  2. package/assets/styles.css +4 -4
  3. package/cucumber.config.js +253 -253
  4. package/docs/ciExecutors.md +198 -198
  5. package/docs/emulationDevicesList.md +152 -152
  6. package/docs/functionDefinitions.md +2401 -2401
  7. package/docs/stepDefinitions.md +435 -433
  8. package/executer.js +266 -264
  9. package/index.js +50 -50
  10. package/package.json +56 -56
  11. package/src/helper/contextManager/browserManager.js +74 -74
  12. package/src/helper/contextManager/requestManager.js +23 -23
  13. package/src/helper/controller/elementController.js +210 -210
  14. package/src/helper/controller/findDuplicateTestNames.js +69 -69
  15. package/src/helper/controller/getEnvInfo.js +94 -94
  16. package/src/helper/controller/getExecutor.js +109 -109
  17. package/src/helper/controller/pomCollector.js +83 -83
  18. package/src/helper/controller/reportCustomizer.js +485 -485
  19. package/src/helper/controller/screenComparer.js +97 -108
  20. package/src/helper/controller/status-formatter.js +137 -137
  21. package/src/helper/controller/testCoverageCalculator.js +111 -111
  22. package/src/helper/executers/cleaner.js +23 -23
  23. package/src/helper/executers/exporter.js +19 -19
  24. package/src/helper/executers/helper.js +193 -191
  25. package/src/helper/executers/projectCreator.js +226 -222
  26. package/src/helper/executers/reportGenerator.js +91 -91
  27. package/src/helper/executers/testRunner.js +28 -28
  28. package/src/helper/executers/versionChecker.js +31 -31
  29. package/src/helper/imports/commons.js +65 -65
  30. package/src/helper/stepFunctions/APIActions.js +495 -495
  31. package/src/helper/stepFunctions/assertions.js +986 -986
  32. package/src/helper/stepFunctions/browserActions.js +87 -87
  33. package/src/helper/stepFunctions/elementInteractions.js +60 -60
  34. package/src/helper/stepFunctions/exporter.js +19 -19
  35. package/src/helper/stepFunctions/frameActions.js +72 -72
  36. package/src/helper/stepFunctions/keyboardActions.js +66 -66
  37. package/src/helper/stepFunctions/mouseActions.js +84 -84
  38. package/src/helper/stepFunctions/pageActions.js +43 -43
  39. package/src/hooks/context.js +15 -15
  40. package/src/hooks/hooks.js +287 -279
  41. package/src/stepDefinitions/API.steps.js +310 -310
  42. package/src/stepDefinitions/assertions.steps.js +1303 -1280
  43. package/src/stepDefinitions/browser.steps.js +74 -74
  44. package/src/stepDefinitions/frameActions.steps.js +76 -76
  45. package/src/stepDefinitions/keyboardActions.steps.js +264 -264
  46. package/src/stepDefinitions/mouseActions.steps.js +378 -378
  47. package/src/stepDefinitions/page.steps.js +71 -71
  48. package/src/stepDefinitions/random.steps.js +191 -191
@@ -1,253 +1,253 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const { moduleConfig } = require("./src/helper/imports/commons");
4
-
5
- let artesConfig = {};
6
-
7
- try {
8
- if (fs.existsSync(moduleConfig.cucumberConfigPath)) {
9
- const artesConf = require(moduleConfig.cucumberConfigPath);
10
- artesConfig = artesConf || {};
11
- }
12
- } catch (error) {
13
- console.warn("Error reading config file:", error.message);
14
- console.log("Proceeding with default config.");
15
- }
16
-
17
- const defaultFormats = [
18
- "rerun:@rerun.txt",
19
- "progress-bar",
20
- "./src/helper/controller/status-formatter.js:null",
21
- ];
22
-
23
- const userFormatsFromEnv = process.env.REPORT_FORMAT
24
- ? JSON.parse(process.env.REPORT_FORMAT)
25
- : [];
26
-
27
- const userFormatsFromConfig = artesConfig.format || [];
28
-
29
- const finalFormats = [
30
- ...new Set([
31
- ...defaultFormats,
32
- ...userFormatsFromEnv,
33
- ...userFormatsFromConfig,
34
- ]),
35
- ];
36
-
37
- function resolveEnv(artesConfig) {
38
- if (typeof artesConfig.baseURL === "object" && artesConfig.baseURL !== null) {
39
- if (
40
- process.env.ENV &&
41
- artesConfig.baseURL.hasOwnProperty(process.env.ENV.trim())
42
- ) {
43
- return process.env.ENV.trim();
44
- } else if (
45
- artesConfig.env &&
46
- artesConfig.baseURL.hasOwnProperty(artesConfig.env.trim())
47
- ) {
48
- return artesConfig.env.trim();
49
- } else {
50
- return Object.keys(artesConfig.baseURL)[0];
51
- }
52
- }
53
-
54
- return process.env.ENV || artesConfig.env || "";
55
- }
56
- const env = resolveEnv(artesConfig);
57
-
58
- function loadVariables(cliVariables, artesConfigVariables) {
59
- if (cliVariables) {
60
- try {
61
- cliVariables = JSON.parse(cliVariables);
62
- } catch (err) {
63
- console.error("Invalid JSON in process.env.VARS:", process.env.VARS);
64
- envVars = {};
65
- }
66
- }
67
-
68
- const mergedVars = {
69
- ...(artesConfigVariables || {}),
70
- ...cliVariables,
71
- };
72
-
73
- return mergedVars;
74
- }
75
-
76
- const resolveFeaturePaths = (basePath, value) => {
77
- return value
78
- .split(",")
79
- .map((p) => p.trim())
80
- .filter(Boolean)
81
- .map((p) => path.join(basePath, p));
82
- };
83
-
84
- module.exports = {
85
- default: {
86
- // File paths and patterns
87
- testPercentage: process.env.PERCENTAGE
88
- ? Number(process.env.PERCENTAGE)
89
- : artesConfig.testPercentage || 0, // number - Percentage of tests to run (0-100)
90
- timeout: process.env.TIMEOUT
91
- ? Number(process.env.TIMEOUT) * 1000
92
- : artesConfig.timeout * 1000 || 30 * 1000, // Default timeout in seconds
93
- paths: process.env.RERUN
94
- ? [path.join("../../", process.env.RERUN)]
95
- : process.env.FEATURES
96
- ? resolveFeaturePaths(moduleConfig.projectPath, process.env.FEATURES)
97
- : artesConfig.features
98
- ? resolveFeaturePaths(moduleConfig.projectPath, artesConfig.features)
99
- : [moduleConfig.featuresPath], // Paths to feature files
100
- require: [
101
- process.env.STEP_DEFINITIONS
102
- ? [path.join(moduleConfig.projectPath, process.env.STEP_DEFINITIONS)]
103
- : artesConfig.steps
104
- ? path.join(moduleConfig.projectPath, artesConfig.steps)
105
- : moduleConfig.stepsPath,
106
- "src/stepDefinitions/*.js",
107
- "src/hooks/hooks.js",
108
- ], // Support code paths (CommonJS)
109
- pomPath: artesConfig.pomPath
110
- ? path.join(moduleConfig.projectPath, artesConfig.pomPath)
111
- : moduleConfig.pomPath,
112
- import: artesConfig.import || [], // Support code paths
113
-
114
- report:
115
- process.env.REPORT_WITH_TRACE === "true" ??
116
- artesConfig.reportWithTrace === "true" ??
117
- process.env.REPORT === "true" ??
118
- artesConfig.report === "true" ??
119
- false, // Generate report
120
- // Formatting and output
121
- successReport: process.env.REPORT_SUCCESS
122
- ? true
123
- : artesConfig.reportSuccess || false, // Include successful tests in report
124
-
125
- trace:
126
- process.env.TRACE === "true"
127
- ? process.env.TRACE
128
- : artesConfig.trace || false, // Enable tracing
129
-
130
- reportWithTrace:
131
- process.env.REPORT_WITH_TRACE === "true"
132
- ? process.env.REPORT_WITH_TRACE
133
- : artesConfig.reportWithTrace || false, // Include trace in report
134
-
135
- format: finalFormats, // Formatter names/paths
136
- formatOptions: artesConfig.formatOptions || {
137
- resultsDir: `allure-result`,
138
- }, // Formatter options
139
-
140
- // Execution options
141
- parallel: process.env.PARALLEL
142
- ? Number(process.env.PARALLEL)
143
- : artesConfig.parallel || 1, // Number of parallel workers
144
- dryRun: process.env.DRYRUN
145
- ? process.env.DRYRUN
146
- : artesConfig.dryRun || false, // Prepare test run without execution
147
- failFast: artesConfig.failFast || false, // Stop on first test failure
148
- forceExit: artesConfig.forceExit || false, // Force process.exit() after tests
149
- strict: artesConfig.strict || true, // Fail on pending steps
150
- backtrace: artesConfig.backtrace || false, // Show full backtrace for errors
151
-
152
- // Filtering and organization
153
- tags: process.env.RUN_TAGS
154
- ? JSON.parse(process.env.RUN_TAGS)
155
- : artesConfig.tags || artesConfig.tags || "", // Tag expression to filter scenarios
156
- name: artesConfig.name || [], // Run scenarios matching regex
157
- order: artesConfig.order || "defined", // Run order (defined/random)
158
- language: artesConfig.language || "en", // Default feature file language
159
-
160
- // Module loading
161
- loader: artesConfig.loader || [], // Module loader specifications
162
- requireModule: artesConfig.requireModule || [], // Transpilation module names
163
-
164
- // Retry logic
165
- retry: process.env.RETRY
166
- ? Number(process.env.RETRY)
167
- : artesConfig.retry || 0, // Retry attempts for failing tests
168
- retryTagFilter: artesConfig.retryTagFilter || "", // Tag expression for retries
169
-
170
- // Publishing
171
- publish: artesConfig.publish || false, // Publish to cucumber.io
172
-
173
- // World parameters
174
- worldParameters: artesConfig.worldParameters || {}, // Custom world parameters
175
- },
176
- report: {
177
- logo: process.env.LOGO
178
- ? process.env.LOGO
179
- : artesConfig?.logo || "./logo.png",
180
- brandName: process.env.BRAND_NAME
181
- ? process.env.BRAND_NAME
182
- : artesConfig?.brandName || "ARTES",
183
- reportName: process.env.REPORT_NAME
184
- ? process.env.REPORT_NAME
185
- : artesConfig?.reportName || "ARTES REPORT",
186
- singleFileReport:
187
- process.env.SINGLE_FILE_REPORT == "true"
188
- ? true
189
- : artesConfig.singleFileReport
190
- ? true
191
- : false,
192
- zip: process.env.ZIP == "true" ? true : artesConfig.zip ? true : false,
193
- },
194
- ai:{
195
- ai: process.env.AI ? process.env.AI : artesConfig?.ai?.ai || false,
196
- url: process.env.AI_URL ? process.env.AI_URL : artesConfig?.ai?.url || "",
197
- model: process.env.AI_MODEL
198
- ? process.env.AI_MODEL
199
- : artesConfig?.ai?.model || "gpt-4o",
200
- key: process.env.AI_KEY
201
- ? process.env.AI_KEY
202
- : artesConfig?.ai?.key || "",
203
- language: process.env.AI_LANGUAGE
204
- ? process.env.AI_LANGUAGE
205
- : artesConfig?.ai?.language || "English",
206
- maxTokens: process.env.MAX_TOKENS
207
- ? parseInt(process.env.MAX_TOKENS)
208
- : artesConfig?.ai?.maxTokens || 4000,
209
- maxReports: process.env.MAX_REPORTS
210
- ? parseInt(process.env.MAX_REPORTS)
211
- : artesConfig?.ai?.maxReports || 10,
212
- },
213
- env: env,
214
- variables: loadVariables(process.env.VARS, artesConfig.variables),
215
- baseURL: process.env.BASE_URL
216
- ? JSON.parse(process.env.BASE_URL)
217
- : artesConfig?.baseURL
218
- ? artesConfig?.baseURL
219
- : "",
220
-
221
- browser: {
222
- browserType: process.env.BROWSER
223
- ? JSON.parse(process.env.BROWSER)
224
- : artesConfig?.browser || "chrome",
225
- device: process.env.DEVICE
226
- ? JSON.parse(process.env.DEVICE)
227
- : artesConfig?.device || null,
228
- offline: process.env.OFFLINE
229
- ? JSON.parse(process.env.OFFLINE)
230
- : artesConfig?.offline || false,
231
- viewport: {
232
- width: process.env.WIDTH
233
- ? Number(process.env.WIDTH)
234
- : artesConfig?.width || 1280,
235
- height: process.env.HEIGHT
236
- ? Number(process.env.HEIGHT)
237
- : artesConfig?.height || 720,
238
- },
239
- maximizeScreen: process.env.MAXIMIZE_SCREEN
240
- ? JSON.parse(process.env.MAXIMIZE_SCREEN)
241
- : artesConfig?.maximizeScreen !== undefined
242
- ? artesConfig.maximizeScreen
243
- : true,
244
- headless: process.env.MODE
245
- ? JSON.parse(process.env.MODE)
246
- : artesConfig?.headless !== undefined
247
- ? artesConfig.headless
248
- : false,
249
- slowMo: process.env.SLOWMO
250
- ? Number(process.env.SLOWMO) * 1000
251
- : artesConfig?.slowMo * 1000 || 0,
252
- },
253
- };
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const { moduleConfig } = require("./src/helper/imports/commons");
4
+
5
+ let artesConfig = {};
6
+
7
+ try {
8
+ if (fs.existsSync(moduleConfig.cucumberConfigPath)) {
9
+ const artesConf = require(moduleConfig.cucumberConfigPath);
10
+ artesConfig = artesConf || {};
11
+ }
12
+ } catch (error) {
13
+ console.warn("Error reading config file:", error.message);
14
+ console.log("Proceeding with default config.");
15
+ }
16
+
17
+ const defaultFormats = [
18
+ "rerun:@rerun.txt",
19
+ "progress-bar",
20
+ "./src/helper/controller/status-formatter.js:null",
21
+ ];
22
+
23
+ const userFormatsFromEnv = process.env.REPORT_FORMAT
24
+ ? JSON.parse(process.env.REPORT_FORMAT)
25
+ : [];
26
+
27
+ const userFormatsFromConfig = artesConfig.format || [];
28
+
29
+ const finalFormats = [
30
+ ...new Set([
31
+ ...defaultFormats,
32
+ ...userFormatsFromEnv,
33
+ ...userFormatsFromConfig,
34
+ ]),
35
+ ];
36
+
37
+ function resolveEnv(artesConfig) {
38
+ if (typeof artesConfig.baseURL === "object" && artesConfig.baseURL !== null) {
39
+ if (
40
+ process.env.ENV &&
41
+ artesConfig.baseURL.hasOwnProperty(process.env.ENV.trim())
42
+ ) {
43
+ return process.env.ENV.trim();
44
+ } else if (
45
+ artesConfig.env &&
46
+ artesConfig.baseURL.hasOwnProperty(artesConfig.env.trim())
47
+ ) {
48
+ return artesConfig.env.trim();
49
+ } else {
50
+ return Object.keys(artesConfig.baseURL)[0];
51
+ }
52
+ }
53
+
54
+ return process.env.ENV || artesConfig.env || "";
55
+ }
56
+ const env = resolveEnv(artesConfig);
57
+
58
+ function loadVariables(cliVariables, artesConfigVariables) {
59
+ if (cliVariables) {
60
+ try {
61
+ cliVariables = JSON.parse(cliVariables);
62
+ } catch (err) {
63
+ console.error("Invalid JSON in process.env.VARS:", process.env.VARS);
64
+ envVars = {};
65
+ }
66
+ }
67
+
68
+ const mergedVars = {
69
+ ...(artesConfigVariables || {}),
70
+ ...cliVariables,
71
+ };
72
+
73
+ return mergedVars;
74
+ }
75
+
76
+ const resolveFeaturePaths = (basePath, value) => {
77
+ return value
78
+ .split(",")
79
+ .map((p) => p.trim())
80
+ .filter(Boolean)
81
+ .map((p) => path.join(basePath, p));
82
+ };
83
+
84
+ module.exports = {
85
+ default: {
86
+ // File paths and patterns
87
+ testPercentage: process.env.PERCENTAGE
88
+ ? Number(process.env.PERCENTAGE)
89
+ : artesConfig.testPercentage || 0, // number - Percentage of tests to run (0-100)
90
+ timeout: process.env.TIMEOUT
91
+ ? Number(process.env.TIMEOUT) * 1000
92
+ : artesConfig.timeout * 1000 || 30 * 1000, // Default timeout in seconds
93
+ paths: process.env.RERUN
94
+ ? [path.join("../../", process.env.RERUN)]
95
+ : process.env.FEATURES
96
+ ? resolveFeaturePaths(moduleConfig.projectPath, process.env.FEATURES)
97
+ : artesConfig.features
98
+ ? resolveFeaturePaths(moduleConfig.projectPath, artesConfig.features)
99
+ : [moduleConfig.featuresPath], // Paths to feature files
100
+ require: [
101
+ process.env.STEP_DEFINITIONS
102
+ ? [path.join(moduleConfig.projectPath, process.env.STEP_DEFINITIONS)]
103
+ : artesConfig.steps
104
+ ? path.join(moduleConfig.projectPath, artesConfig.steps)
105
+ : moduleConfig.stepsPath,
106
+ "src/stepDefinitions/*.js",
107
+ "src/hooks/hooks.js",
108
+ ], // Support code paths (CommonJS)
109
+ pomPath: artesConfig.pomPath
110
+ ? path.join(moduleConfig.projectPath, artesConfig.pomPath)
111
+ : moduleConfig.pomPath,
112
+ import: artesConfig.import || [], // Support code paths
113
+
114
+ report:
115
+ process.env.REPORT_WITH_TRACE === "true" ??
116
+ artesConfig.reportWithTrace === "true" ??
117
+ process.env.REPORT === "true" ??
118
+ artesConfig.report === "true" ??
119
+ false, // Generate report
120
+ // Formatting and output
121
+ successReport: process.env.REPORT_SUCCESS
122
+ ? true
123
+ : artesConfig.reportSuccess || false, // Include successful tests in report
124
+
125
+ trace:
126
+ process.env.TRACE === "true"
127
+ ? process.env.TRACE
128
+ : artesConfig.trace || false, // Enable tracing
129
+
130
+ reportWithTrace:
131
+ process.env.REPORT_WITH_TRACE === "true"
132
+ ? process.env.REPORT_WITH_TRACE
133
+ : artesConfig.reportWithTrace || false, // Include trace in report
134
+
135
+ format: finalFormats, // Formatter names/paths
136
+ formatOptions: artesConfig.formatOptions || {
137
+ resultsDir: `allure-result`,
138
+ }, // Formatter options
139
+
140
+ // Execution options
141
+ parallel: process.env.PARALLEL
142
+ ? Number(process.env.PARALLEL)
143
+ : artesConfig.parallel || 1, // Number of parallel workers
144
+ dryRun: process.env.DRYRUN
145
+ ? process.env.DRYRUN
146
+ : artesConfig.dryRun || false, // Prepare test run without execution
147
+ failFast: artesConfig.failFast || false, // Stop on first test failure
148
+ forceExit: artesConfig.forceExit || false, // Force process.exit() after tests
149
+ strict: artesConfig.strict || true, // Fail on pending steps
150
+ backtrace: artesConfig.backtrace || false, // Show full backtrace for errors
151
+
152
+ // Filtering and organization
153
+ tags: process.env.RUN_TAGS
154
+ ? JSON.parse(process.env.RUN_TAGS)
155
+ : artesConfig.tags || artesConfig.tags || "", // Tag expression to filter scenarios
156
+ name: artesConfig.name || [], // Run scenarios matching regex
157
+ order: artesConfig.order || "defined", // Run order (defined/random)
158
+ language: artesConfig.language || "en", // Default feature file language
159
+
160
+ // Module loading
161
+ loader: artesConfig.loader || [], // Module loader specifications
162
+ requireModule: artesConfig.requireModule || [], // Transpilation module names
163
+
164
+ // Retry logic
165
+ retry: process.env.RETRY
166
+ ? Number(process.env.RETRY)
167
+ : artesConfig.retry || 0, // Retry attempts for failing tests
168
+ retryTagFilter: artesConfig.retryTagFilter || "", // Tag expression for retries
169
+
170
+ // Publishing
171
+ publish: artesConfig.publish || false, // Publish to cucumber.io
172
+
173
+ // World parameters
174
+ worldParameters: artesConfig.worldParameters || {}, // Custom world parameters
175
+ },
176
+ report: {
177
+ logo: process.env.LOGO
178
+ ? process.env.LOGO
179
+ : artesConfig?.logo || "./logo.png",
180
+ brandName: process.env.BRAND_NAME
181
+ ? process.env.BRAND_NAME
182
+ : artesConfig?.brandName || "ARTES",
183
+ reportName: process.env.REPORT_NAME
184
+ ? process.env.REPORT_NAME
185
+ : artesConfig?.reportName || "ARTES REPORT",
186
+ singleFileReport:
187
+ process.env.SINGLE_FILE_REPORT == "true"
188
+ ? true
189
+ : artesConfig.singleFileReport
190
+ ? true
191
+ : false,
192
+ zip: process.env.ZIP == "true" ? true : artesConfig.zip ? true : false,
193
+ },
194
+ ai:{
195
+ ai: process.env.AI ? process.env.AI : artesConfig?.ai?.ai || false,
196
+ url: process.env.AI_URL ? process.env.AI_URL : artesConfig?.ai?.url || "",
197
+ model: process.env.AI_MODEL
198
+ ? process.env.AI_MODEL
199
+ : artesConfig?.ai?.model || "gpt-4o",
200
+ key: process.env.AI_KEY
201
+ ? process.env.AI_KEY
202
+ : artesConfig?.ai?.key || "",
203
+ language: process.env.AI_LANGUAGE
204
+ ? process.env.AI_LANGUAGE
205
+ : artesConfig?.ai?.language || "English",
206
+ maxTokens: process.env.MAX_TOKENS
207
+ ? parseInt(process.env.MAX_TOKENS)
208
+ : artesConfig?.ai?.maxTokens || 4000,
209
+ maxReports: process.env.MAX_REPORTS
210
+ ? parseInt(process.env.MAX_REPORTS)
211
+ : artesConfig?.ai?.maxReports || 10,
212
+ },
213
+ env: env,
214
+ variables: loadVariables(process.env.VARS, artesConfig.variables),
215
+ baseURL: process.env.BASE_URL
216
+ ? JSON.parse(process.env.BASE_URL)
217
+ : artesConfig?.baseURL
218
+ ? artesConfig?.baseURL
219
+ : "",
220
+
221
+ browser: {
222
+ browserType: process.env.BROWSER
223
+ ? JSON.parse(process.env.BROWSER)
224
+ : artesConfig?.browser || "chrome",
225
+ device: process.env.DEVICE
226
+ ? JSON.parse(process.env.DEVICE)
227
+ : artesConfig?.device || null,
228
+ offline: process.env.OFFLINE
229
+ ? JSON.parse(process.env.OFFLINE)
230
+ : artesConfig?.offline || false,
231
+ viewport: {
232
+ width: process.env.WIDTH
233
+ ? Number(process.env.WIDTH)
234
+ : artesConfig?.width || 1280,
235
+ height: process.env.HEIGHT
236
+ ? Number(process.env.HEIGHT)
237
+ : artesConfig?.height || 720,
238
+ },
239
+ maximizeScreen: process.env.MAXIMIZE_SCREEN
240
+ ? JSON.parse(process.env.MAXIMIZE_SCREEN)
241
+ : artesConfig?.maximizeScreen !== undefined
242
+ ? artesConfig.maximizeScreen
243
+ : true,
244
+ headless: process.env.MODE
245
+ ? JSON.parse(process.env.MODE)
246
+ : artesConfig?.headless !== undefined
247
+ ? artesConfig.headless
248
+ : false,
249
+ slowMo: process.env.SLOWMO
250
+ ? Number(process.env.SLOWMO) * 1000
251
+ : artesConfig?.slowMo * 1000 || 0,
252
+ },
253
+ };