artes 1.4.7 → 1.4.9

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 (40) hide show
  1. package/README.md +668 -668
  2. package/cucumber.config.js +223 -223
  3. package/docs/emulationDevicesList.md +152 -152
  4. package/docs/functionDefinitions.md +2401 -2401
  5. package/docs/stepDefinitions.md +402 -402
  6. package/executer.js +479 -479
  7. package/index.js +50 -50
  8. package/package.json +52 -52
  9. package/src/helper/contextManager/browserManager.js +74 -74
  10. package/src/helper/contextManager/requestManager.js +23 -23
  11. package/src/helper/controller/elementController.js +203 -185
  12. package/src/helper/controller/pomCollector.js +82 -82
  13. package/src/helper/executers/cleaner.js +19 -19
  14. package/src/helper/executers/exporter.js +15 -15
  15. package/src/helper/executers/helper.js +110 -110
  16. package/src/helper/executers/projectCreator.js +206 -206
  17. package/src/helper/executers/reportGenerator.js +70 -70
  18. package/src/helper/executers/testRunner.js +28 -28
  19. package/src/helper/executers/versionChecker.js +31 -31
  20. package/src/helper/imports/commons.js +57 -57
  21. package/src/helper/stepFunctions/APIActions.js +495 -495
  22. package/src/helper/stepFunctions/assertions.js +989 -989
  23. package/src/helper/stepFunctions/browserActions.js +22 -22
  24. package/src/helper/stepFunctions/elementInteractions.js +60 -60
  25. package/src/helper/stepFunctions/exporter.js +19 -19
  26. package/src/helper/stepFunctions/frameActions.js +72 -72
  27. package/src/helper/stepFunctions/keyboardActions.js +66 -66
  28. package/src/helper/stepFunctions/mouseActions.js +83 -83
  29. package/src/helper/stepFunctions/pageActions.js +43 -43
  30. package/src/hooks/context.js +15 -15
  31. package/src/hooks/hooks.js +215 -215
  32. package/src/stepDefinitions/API.steps.js +310 -310
  33. package/src/stepDefinitions/assertions.steps.js +1092 -1092
  34. package/src/stepDefinitions/browser.steps.js +7 -7
  35. package/src/stepDefinitions/frameActions.steps.js +76 -76
  36. package/src/stepDefinitions/keyboardActions.steps.js +265 -265
  37. package/src/stepDefinitions/mouseActions.steps.js +378 -378
  38. package/src/stepDefinitions/page.steps.js +71 -71
  39. package/src/stepDefinitions/random.steps.js +188 -188
  40. package/status-formatter.js +138 -138
@@ -1,43 +1,43 @@
1
- const { context, selector, resolveVariable } = require("../imports/commons");
2
-
3
- const page = {
4
- navigateTo: async (url, options) => {
5
- options = options ?? {};
6
-
7
- url = await resolveVariable(url);
8
- url = await selector(url);
9
-
10
- return await context.page.goto(url, options);
11
- },
12
- getURL: async (options) => {
13
- options = options ?? {};
14
-
15
- return await context.page.url(options);
16
- },
17
- navigateBack: async (options) => {
18
- options = options ?? {};
19
-
20
- return await context.page.goBack(options);
21
- },
22
- navigateForward: async (options) => {
23
- options = options ?? {};
24
-
25
- return await context.page.goForward(options);
26
- },
27
- reload: async (options) => {
28
- options = options ?? {};
29
-
30
- return await context.page.reload(options);
31
- },
32
- wait: async (time, options) => {
33
- options = options ?? {};
34
-
35
- time = await resolveVariable(time);
36
-
37
- return await context.page.waitForTimeout(time, options);
38
- },
39
- };
40
-
41
- module.exports = {
42
- page,
43
- };
1
+ const { context, selector, resolveVariable } = require("../imports/commons");
2
+
3
+ const page = {
4
+ navigateTo: async (url, options) => {
5
+ options = options ?? {};
6
+
7
+ url = await resolveVariable(url);
8
+ url = await selector(url);
9
+
10
+ return await context.page.goto(url, options);
11
+ },
12
+ getURL: async (options) => {
13
+ options = options ?? {};
14
+
15
+ return await context.page.url(options);
16
+ },
17
+ navigateBack: async (options) => {
18
+ options = options ?? {};
19
+
20
+ return await context.page.goBack(options);
21
+ },
22
+ navigateForward: async (options) => {
23
+ options = options ?? {};
24
+
25
+ return await context.page.goForward(options);
26
+ },
27
+ reload: async (options) => {
28
+ options = options ?? {};
29
+
30
+ return await context.page.reload(options);
31
+ },
32
+ wait: async (time, options) => {
33
+ options = options ?? {};
34
+
35
+ time = await resolveVariable(time);
36
+
37
+ return await context.page.waitForTimeout(time, options);
38
+ },
39
+ };
40
+
41
+ module.exports = {
42
+ page,
43
+ };
@@ -1,15 +1,15 @@
1
- class Context {
2
- constructor() {
3
- this.browser = undefined;
4
- this.page = undefined;
5
- this.request = undefined;
6
- this.response = undefined;
7
- this.vars = undefined;
8
- }
9
- }
10
-
11
- const context = new Context();
12
-
13
- module.exports = {
14
- context,
15
- };
1
+ class Context {
2
+ constructor() {
3
+ this.browser = undefined;
4
+ this.page = undefined;
5
+ this.request = undefined;
6
+ this.response = undefined;
7
+ this.vars = undefined;
8
+ }
9
+ }
10
+
11
+ const context = new Context();
12
+
13
+ module.exports = {
14
+ context,
15
+ };
@@ -1,215 +1,215 @@
1
- const {
2
- BeforeAll,
3
- Before,
4
- After,
5
- Status,
6
- setDefaultTimeout,
7
- AfterStep,
8
- BeforeStep,
9
- AfterAll,
10
- } = require("@cucumber/cucumber");
11
- const { invokeBrowser } = require("../helper/contextManager/browserManager");
12
- const { invokeRequest } = require("../helper/contextManager/requestManager");
13
- const {
14
- pomCollector
15
- } = require("../helper/controller/pomCollector");
16
- const cucumberConfig = require("../../cucumber.config");
17
- const { context } = require("./context");
18
- const fs = require("fs");
19
- const path = require("path");
20
- const { moduleConfig, saveVar } = require("artes/src/helper/imports/commons");
21
- require("allure-cucumberjs");
22
- const allure = require("allure-js-commons");
23
-
24
- const statusDir = path.join(process.cwd(), "testsStatus");
25
- const HTTP_METHODS = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"];
26
-
27
- /* ------------------- Helpers ------------------- */
28
-
29
- setDefaultTimeout(cucumberConfig.default.timeout);
30
-
31
- async function attachResponse(attachFn) {
32
- if (!context.response) return;
33
-
34
- for (const [key, value] of Object.entries(context.response)) {
35
- const text =
36
- typeof value === "object"
37
- ? `${key}:\n${JSON.stringify(value, null, 2)}`
38
- : `${key}:\n${value}`;
39
-
40
- await attachFn(key, text, "application/json");
41
- }
42
- }
43
-
44
- const projectHooksPath = path.resolve(
45
- moduleConfig.projectPath,
46
- "tests/steps/hooks.js",
47
- );
48
-
49
- let projectHooks = {};
50
-
51
- if (fs.existsSync(projectHooksPath)) {
52
- try {
53
- projectHooks = require(projectHooksPath);
54
- } catch (err) {
55
- console.warn("⚠️ Failed to load project hooks.js:", err.message);
56
- }
57
- } else {
58
- projectHooks = {};
59
- }
60
-
61
- /* ------------------- Hooks ------------------- */
62
-
63
- BeforeAll(async () => {
64
- if (typeof projectHooks.BeforeAll === "function") {
65
- await projectHooks.BeforeAll();
66
- }
67
-
68
- pomCollector();
69
- });
70
-
71
- Before(async function ({pickle}) {
72
- context.vars = {};
73
-
74
- const vars = await cucumberConfig.variables
75
-
76
- if (vars && typeof vars === "object") {
77
- for (let [key, value] of Object.entries(vars)) {
78
-
79
- saveVar(value, key);
80
- }
81
- }
82
-
83
- const envFilePath = path.join(
84
- moduleConfig.projectPath,
85
- "tests",
86
- "environment_variables",
87
- `${cucumberConfig.env}.env.json`,
88
- );
89
-
90
- if (fs.existsSync(envFilePath)) {
91
- let env_vars = fs.readFileSync(envFilePath, "utf-8");
92
- try {
93
- env_vars = JSON.parse(env_vars);
94
- context.vars = { ...context.vars, ...env_vars };
95
- } catch (err) {
96
- console.error("Error parsing environment variables JSON:", err);
97
- }
98
- }
99
-
100
- const { browser, context: browserContext } = await invokeBrowser();
101
- const requestInstance = await invokeRequest();
102
-
103
- context.browser = browser;
104
- context.browserContext = browserContext;
105
- context.page = await browserContext.newPage();
106
- context.request = requestInstance;
107
-
108
- await context.page.setDefaultTimeout(cucumberConfig.default.timeout);
109
-
110
- if (cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) {
111
- await browserContext.tracing.start({
112
- title: pickle.name,
113
- sources: true,
114
- screenshots: true,
115
- snapshots: true,
116
- });
117
- }
118
-
119
- if (typeof projectHooks.Before === "function") {
120
- await projectHooks.Before();
121
- }
122
- });
123
-
124
- BeforeStep(async ({ pickleStep }) => {
125
- if (HTTP_METHODS.some((method) => pickleStep.text.includes(method))) {
126
- context.response = {};
127
- }
128
-
129
- if (typeof projectHooks.BeforeStep === "function") {
130
- await projectHooks.BeforeStep();
131
- }
132
- });
133
-
134
- AfterStep(async function ({ pickleStep }) {
135
- if (typeof projectHooks.AfterStep === "function") {
136
- await projectHooks.AfterStep();
137
- }
138
-
139
- if (HTTP_METHODS.some((method) => pickleStep.text.includes(method))) {
140
- await attachResponse(allure.attachment);
141
- }
142
- });
143
-
144
- After(async function ({result, pickle}) {
145
- if (typeof projectHooks.After === "function") {
146
- await projectHooks.After();
147
- }
148
-
149
- await attachResponse(allure.attachment);
150
- context.response = await {};
151
- allure.attachment('Variables', JSON.stringify(context.vars, null, 2), 'application/json')
152
-
153
- const shouldReport =
154
- cucumberConfig.default.successReport || result?.status !== Status.PASSED;
155
-
156
- if (shouldReport & (context.page.url() !== "about:blank")) {
157
- const screenshotBuffer = await context.page.screenshot({ type: "png" });
158
-
159
- await allure.attachment("Screenshot", screenshotBuffer, "image/png");
160
- }
161
-
162
-
163
- if (cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) {
164
- var tracePath = path.join(
165
- moduleConfig.projectPath,
166
- `./traces/${pickle.name.replaceAll(" ", "_")}-${pickle.id}.zip`,
167
- );
168
- }
169
-
170
- if (
171
- (cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) &&
172
- shouldReport &&
173
- context.page.url() !== "about:blank"
174
- ) {
175
- await context.browserContext.tracing.stop({
176
- path: tracePath,
177
- });
178
-
179
- if (cucumberConfig.default.reportWithTrace) {
180
- await allure.attachTrace("Trace", tracePath);
181
-
182
- }
183
- }
184
-
185
-
186
- await context.page?.close();
187
- await context.browserContext?.close();
188
- await context.browser?.close();
189
- await context.request?.dispose();
190
-
191
- if (
192
- shouldReport &&
193
- context.page.video &&
194
- context.page.url() !== "about:blank"
195
- ) {
196
- const video = context.page.video();
197
- if (video) {
198
- const videoPath = await video.path();
199
-
200
- await new Promise((resolve) => setTimeout(resolve, 1000));
201
-
202
- if (fs.existsSync(videoPath)) {
203
- const webmBuffer = fs.readFileSync(videoPath);
204
- await allure.attachment("Screenrecord", webmBuffer, "video/webm");
205
- }
206
- }
207
- }
208
- });
209
-
210
- AfterAll(async () => {
211
- if (typeof projectHooks.AfterAll === "function") {
212
- await projectHooks.AfterAll();
213
- }
214
-
215
- });
1
+ const {
2
+ BeforeAll,
3
+ Before,
4
+ After,
5
+ Status,
6
+ setDefaultTimeout,
7
+ AfterStep,
8
+ BeforeStep,
9
+ AfterAll,
10
+ } = require("@cucumber/cucumber");
11
+ const { invokeBrowser } = require("../helper/contextManager/browserManager");
12
+ const { invokeRequest } = require("../helper/contextManager/requestManager");
13
+ const {
14
+ pomCollector
15
+ } = require("../helper/controller/pomCollector");
16
+ const cucumberConfig = require("../../cucumber.config");
17
+ const { context } = require("./context");
18
+ const fs = require("fs");
19
+ const path = require("path");
20
+ const { moduleConfig, saveVar } = require("artes/src/helper/imports/commons");
21
+ require("allure-cucumberjs");
22
+ const allure = require("allure-js-commons");
23
+
24
+ const statusDir = path.join(process.cwd(), "testsStatus");
25
+ const HTTP_METHODS = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"];
26
+
27
+ /* ------------------- Helpers ------------------- */
28
+
29
+ setDefaultTimeout(cucumberConfig.default.timeout);
30
+
31
+ async function attachResponse(attachFn) {
32
+ if (!context.response) return;
33
+
34
+ for (const [key, value] of Object.entries(context.response)) {
35
+ const text =
36
+ typeof value === "object"
37
+ ? `${key}:\n${JSON.stringify(value, null, 2)}`
38
+ : `${key}:\n${value}`;
39
+
40
+ await attachFn(key, text, "application/json");
41
+ }
42
+ }
43
+
44
+ const projectHooksPath = path.resolve(
45
+ moduleConfig.projectPath,
46
+ "tests/steps/hooks.js",
47
+ );
48
+
49
+ let projectHooks = {};
50
+
51
+ if (fs.existsSync(projectHooksPath)) {
52
+ try {
53
+ projectHooks = require(projectHooksPath);
54
+ } catch (err) {
55
+ console.warn("⚠️ Failed to load project hooks.js:", err.message);
56
+ }
57
+ } else {
58
+ projectHooks = {};
59
+ }
60
+
61
+ /* ------------------- Hooks ------------------- */
62
+
63
+ BeforeAll(async () => {
64
+ if (typeof projectHooks.BeforeAll === "function") {
65
+ await projectHooks.BeforeAll();
66
+ }
67
+
68
+ pomCollector();
69
+ });
70
+
71
+ Before(async function ({pickle}) {
72
+ context.vars = {};
73
+
74
+ const vars = await cucumberConfig.variables
75
+
76
+ if (vars && typeof vars === "object") {
77
+ for (let [key, value] of Object.entries(vars)) {
78
+
79
+ saveVar(value, key);
80
+ }
81
+ }
82
+
83
+ const envFilePath = path.join(
84
+ moduleConfig.projectPath,
85
+ "tests",
86
+ "environment_variables",
87
+ `${cucumberConfig.env}.env.json`,
88
+ );
89
+
90
+ if (fs.existsSync(envFilePath)) {
91
+ let env_vars = fs.readFileSync(envFilePath, "utf-8");
92
+ try {
93
+ env_vars = JSON.parse(env_vars);
94
+ context.vars = { ...context.vars, ...env_vars };
95
+ } catch (err) {
96
+ console.error("Error parsing environment variables JSON:", err);
97
+ }
98
+ }
99
+
100
+ const { browser, context: browserContext } = await invokeBrowser();
101
+ const requestInstance = await invokeRequest();
102
+
103
+ context.browser = browser;
104
+ context.browserContext = browserContext;
105
+ context.page = await browserContext.newPage();
106
+ context.request = requestInstance;
107
+
108
+ await context.page.setDefaultTimeout(cucumberConfig.default.timeout);
109
+
110
+ if (cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) {
111
+ await browserContext.tracing.start({
112
+ title: pickle.name,
113
+ sources: true,
114
+ screenshots: true,
115
+ snapshots: true,
116
+ });
117
+ }
118
+
119
+ if (typeof projectHooks.Before === "function") {
120
+ await projectHooks.Before();
121
+ }
122
+ });
123
+
124
+ BeforeStep(async ({ pickleStep }) => {
125
+ if (HTTP_METHODS.some((method) => pickleStep.text.includes(method))) {
126
+ context.response = {};
127
+ }
128
+
129
+ if (typeof projectHooks.BeforeStep === "function") {
130
+ await projectHooks.BeforeStep();
131
+ }
132
+ });
133
+
134
+ AfterStep(async function ({ pickleStep }) {
135
+ if (typeof projectHooks.AfterStep === "function") {
136
+ await projectHooks.AfterStep();
137
+ }
138
+
139
+ if (HTTP_METHODS.some((method) => pickleStep.text.includes(method))) {
140
+ await attachResponse(allure.attachment);
141
+ }
142
+ });
143
+
144
+ After(async function ({result, pickle}) {
145
+ if (typeof projectHooks.After === "function") {
146
+ await projectHooks.After();
147
+ }
148
+
149
+ await attachResponse(allure.attachment);
150
+ context.response = await {};
151
+ allure.attachment('Variables', JSON.stringify(context.vars, null, 2), 'application/json')
152
+
153
+ const shouldReport =
154
+ cucumberConfig.default.successReport || result?.status !== Status.PASSED;
155
+
156
+ if (shouldReport & (context.page.url() !== "about:blank")) {
157
+ const screenshotBuffer = await context.page.screenshot({ type: "png" });
158
+
159
+ await allure.attachment("Screenshot", screenshotBuffer, "image/png");
160
+ }
161
+
162
+
163
+ if (cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) {
164
+ var tracePath = path.join(
165
+ moduleConfig.projectPath,
166
+ `./traces/${pickle.name.replaceAll(" ", "_")}-${pickle.id}.zip`,
167
+ );
168
+ }
169
+
170
+ if (
171
+ (cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) &&
172
+ shouldReport &&
173
+ context.page.url() !== "about:blank"
174
+ ) {
175
+ await context.browserContext.tracing.stop({
176
+ path: tracePath,
177
+ });
178
+
179
+ if (cucumberConfig.default.reportWithTrace) {
180
+ await allure.attachTrace("Trace", tracePath);
181
+
182
+ }
183
+ }
184
+
185
+
186
+ await context.page?.close();
187
+ await context.browserContext?.close();
188
+ await context.browser?.close();
189
+ await context.request?.dispose();
190
+
191
+ if (
192
+ shouldReport &&
193
+ context.page.video &&
194
+ context.page.url() !== "about:blank"
195
+ ) {
196
+ const video = context.page.video();
197
+ if (video) {
198
+ const videoPath = await video.path();
199
+
200
+ await new Promise((resolve) => setTimeout(resolve, 1000));
201
+
202
+ if (fs.existsSync(videoPath)) {
203
+ const webmBuffer = fs.readFileSync(videoPath);
204
+ await allure.attachment("Screenrecord", webmBuffer, "video/webm");
205
+ }
206
+ }
207
+ }
208
+ });
209
+
210
+ AfterAll(async () => {
211
+ if (typeof projectHooks.AfterAll === "function") {
212
+ await projectHooks.AfterAll();
213
+ }
214
+
215
+ });