artes 1.7.20 → 1.7.21

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 (49) hide show
  1. package/README.md +781 -781
  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 -435
  8. package/executer.js +266 -266
  9. package/index.js +51 -51
  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 +230 -230
  14. package/src/helper/controller/findDuplicateTestNames.js +69 -69
  15. package/src/helper/controller/getEnvInfo.js +97 -97
  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 +511 -511
  19. package/src/helper/controller/screenComparer.js +96 -96
  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 -193
  25. package/src/helper/executers/projectCreator.js +226 -226
  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 +69 -69
  30. package/src/helper/stepFunctions/APIActions.js +582 -582
  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 +18 -18
  40. package/src/hooks/hooks.js +287 -287
  41. package/src/stepDefinitions/API.steps.js +404 -404
  42. package/src/stepDefinitions/assertions.steps.js +1358 -1349
  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 +374 -374
  47. package/src/stepDefinitions/page.steps.js +71 -71
  48. package/src/stepDefinitions/random.steps.js +199 -199
  49. package/src/stepDefinitions/report.steps.js +5 -5
@@ -1,98 +1,98 @@
1
- const os = require("os");
2
- const fs = require("fs");
3
- const path = require("path");
4
- const { moduleConfig } = require("artes/src/helper/imports/commons");
5
-
6
- async function getEnvInfo() {
7
- delete require.cache[require.resolve("../../../cucumber.config.js")];
8
- const cucumberConfig = require("../../../cucumber.config.js");
9
-
10
- let baseURL = "";
11
-
12
- if (typeof cucumberConfig.baseURL === "object") {
13
- const env = (cucumberConfig.env || "").trim();
14
- baseURL = cucumberConfig.baseURL[env];
15
- } else {
16
- baseURL = cucumberConfig.baseURL;
17
- }
18
-
19
- let browserInfo = null;
20
- if (fs.existsSync(path.join(moduleConfig.modulePath, "browser-info.json"))) {
21
- browserInfo = JSON.parse(
22
- fs.readFileSync(
23
- path.join(moduleConfig.modulePath, "browser-info.json"),
24
- "utf8",
25
- ),
26
- );
27
- }
28
-
29
- const environment = {
30
- // ── ARTES Version ───────────────────────
31
- ARTES_Version: require(moduleConfig.modulePackageJsonPath).version,
32
-
33
- // ── System ──────────────────────────────
34
- OS_Name: os.type(),
35
- OS_Version: os.release(),
36
- OS_Platform: process.platform,
37
- OS_Arch: os.arch(),
38
- CPU_Cores: os.cpus().length,
39
- CPU_Model: os.cpus()[0]?.model ?? "N/A",
40
- RAM_Total: `${(os.totalmem() / 1024 / 1024 / 1024).toFixed(2)} GB`,
41
- RAM_Free: `${(os.freemem() / 1024 / 1024 / 1024).toFixed(2)} GB`,
42
- Hostname: os.hostname(),
43
-
44
- // ── Node ────────────────────────────────
45
- Node_Version: process.version,
46
- NPM_Version: process.env.npm_config_user_agent ?? "N/A",
47
- Working_Dir: process.cwd(),
48
-
49
- // ── Browser ─────────────────────────────
50
- Browser_Name: cucumberConfig.browser.browserType,
51
- Browser_Version: browserInfo?.BROWSER_VERSION ?? "N/A",
52
- Screen_Size: `w: ${browserInfo?.BROWSER_WIDTH ?? "N/A"}px h:${browserInfo?.BROWSER_HEIGHT ?? "N/A"}px`,
53
- Headless: cucumberConfig.browser.headless ?? "N/A",
54
-
55
- // ── Test Config ─────────────────────────
56
- Base_URL: baseURL || "N/A",
57
- Environment: cucumberConfig.env || "local",
58
- Parallel_Runner: cucumberConfig.default.parallel,
59
- Timeout: cucumberConfig.default.timeout ?? "N/A",
60
-
61
- // ── AI Config ─────────────────────────
62
- AI_Enabled: cucumberConfig.ai.ai ?? false,
63
- AI_URL: cucumberConfig.ai.url || "N/A",
64
- AI_Model: cucumberConfig.ai.model || "N/A",
65
- AI_Language: cucumberConfig.ai.language || "English",
66
- AI_Max_Tokens: cucumberConfig.ai.maxTokens ?? "4000",
67
- AI_Max_Reports: cucumberConfig.ai.maxReports ?? 10,
68
-
69
- // ── Git ─────────────────────────────────
70
- Git_Branch: process.env.GIT_BRANCH ?? process.env.BRANCH_NAME ?? "N/A",
71
- Git_Commit: process.env.GIT_COMMIT ?? process.env.GIT_SHA ?? "N/A",
72
- Git_Author: process.env.GIT_AUTHOR ?? "N/A",
73
-
74
- // ── Timestamps ──────────────────────────
75
- Run_Date: new Date().toLocaleDateString(),
76
- Run_Time: new Date().toLocaleTimeString(),
77
- Timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
78
- };
79
-
80
- const allureResultsDir = path.join(moduleConfig.modulePath, "allure-result");
81
-
82
- if (!fs.existsSync(allureResultsDir)) {
83
- fs.mkdirSync(allureResultsDir, { recursive: true });
84
- }
85
-
86
- const propertiesContent = Object.entries(environment)
87
- .map(([key, value]) => `${key}=${value}`)
88
- .join("\n");
89
-
90
- fs.writeFileSync(
91
- path.join(allureResultsDir, "environment.properties"),
92
- propertiesContent,
93
- );
94
-
95
- return environment;
96
- }
97
-
1
+ const os = require("os");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const { moduleConfig } = require("artes/src/helper/imports/commons");
5
+
6
+ async function getEnvInfo() {
7
+ delete require.cache[require.resolve("../../../cucumber.config.js")];
8
+ const cucumberConfig = require("../../../cucumber.config.js");
9
+
10
+ let baseURL = "";
11
+
12
+ if (typeof cucumberConfig.baseURL === "object") {
13
+ const env = (cucumberConfig.env || "").trim();
14
+ baseURL = cucumberConfig.baseURL[env];
15
+ } else {
16
+ baseURL = cucumberConfig.baseURL;
17
+ }
18
+
19
+ let browserInfo = null;
20
+ if (fs.existsSync(path.join(moduleConfig.modulePath, "browser-info.json"))) {
21
+ browserInfo = JSON.parse(
22
+ fs.readFileSync(
23
+ path.join(moduleConfig.modulePath, "browser-info.json"),
24
+ "utf8",
25
+ ),
26
+ );
27
+ }
28
+
29
+ const environment = {
30
+ // ── ARTES Version ───────────────────────
31
+ ARTES_Version: require(moduleConfig.modulePackageJsonPath).version,
32
+
33
+ // ── System ──────────────────────────────
34
+ OS_Name: os.type(),
35
+ OS_Version: os.release(),
36
+ OS_Platform: process.platform,
37
+ OS_Arch: os.arch(),
38
+ CPU_Cores: os.cpus().length,
39
+ CPU_Model: os.cpus()[0]?.model ?? "N/A",
40
+ RAM_Total: `${(os.totalmem() / 1024 / 1024 / 1024).toFixed(2)} GB`,
41
+ RAM_Free: `${(os.freemem() / 1024 / 1024 / 1024).toFixed(2)} GB`,
42
+ Hostname: os.hostname(),
43
+
44
+ // ── Node ────────────────────────────────
45
+ Node_Version: process.version,
46
+ NPM_Version: process.env.npm_config_user_agent ?? "N/A",
47
+ Working_Dir: process.cwd(),
48
+
49
+ // ── Browser ─────────────────────────────
50
+ Browser_Name: cucumberConfig.browser.browserType,
51
+ Browser_Version: browserInfo?.BROWSER_VERSION ?? "N/A",
52
+ Screen_Size: `w: ${browserInfo?.BROWSER_WIDTH ?? "N/A"}px h:${browserInfo?.BROWSER_HEIGHT ?? "N/A"}px`,
53
+ Headless: cucumberConfig.browser.headless ?? "N/A",
54
+
55
+ // ── Test Config ─────────────────────────
56
+ Base_URL: baseURL || "N/A",
57
+ Environment: cucumberConfig.env || "local",
58
+ Parallel_Runner: cucumberConfig.default.parallel,
59
+ Timeout: cucumberConfig.default.timeout ?? "N/A",
60
+
61
+ // ── AI Config ─────────────────────────
62
+ AI_Enabled: cucumberConfig.ai.ai ?? false,
63
+ AI_URL: cucumberConfig.ai.url || "N/A",
64
+ AI_Model: cucumberConfig.ai.model || "N/A",
65
+ AI_Language: cucumberConfig.ai.language || "English",
66
+ AI_Max_Tokens: cucumberConfig.ai.maxTokens ?? "4000",
67
+ AI_Max_Reports: cucumberConfig.ai.maxReports ?? 10,
68
+
69
+ // ── Git ─────────────────────────────────
70
+ Git_Branch: process.env.GIT_BRANCH ?? process.env.BRANCH_NAME ?? "N/A",
71
+ Git_Commit: process.env.GIT_COMMIT ?? process.env.GIT_SHA ?? "N/A",
72
+ Git_Author: process.env.GIT_AUTHOR ?? "N/A",
73
+
74
+ // ── Timestamps ──────────────────────────
75
+ Run_Date: new Date().toLocaleDateString(),
76
+ Run_Time: new Date().toLocaleTimeString(),
77
+ Timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
78
+ };
79
+
80
+ const allureResultsDir = path.join(moduleConfig.modulePath, "allure-result");
81
+
82
+ if (!fs.existsSync(allureResultsDir)) {
83
+ fs.mkdirSync(allureResultsDir, { recursive: true });
84
+ }
85
+
86
+ const propertiesContent = Object.entries(environment)
87
+ .map(([key, value]) => `${key}=${value}`)
88
+ .join("\n");
89
+
90
+ fs.writeFileSync(
91
+ path.join(allureResultsDir, "environment.properties"),
92
+ propertiesContent,
93
+ );
94
+
95
+ return environment;
96
+ }
97
+
98
98
  module.exports = { getEnvInfo };
@@ -1,109 +1,109 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
-
4
- function getExecutor() {
5
- let executor;
6
-
7
- if (process.env.GITHUB_RUN_ID) {
8
- executor = {
9
- name: "GitHub Actions",
10
- type: "github",
11
- buildName: `Workflow #${process.env.GITHUB_RUN_NUMBER}`,
12
- buildOrder: Number(process.env.GITHUB_RUN_NUMBER),
13
- buildUrl: `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`,
14
- };
15
- } else if (process.env.JENKINS_HOME) {
16
- executor = {
17
- name: "Jenkins",
18
- type: "jenkins",
19
- buildName: process.env.JOB_NAME || "Manual Run",
20
- buildOrder: Number(process.env.BUILD_NUMBER) || 1,
21
- buildUrl: process.env.BUILD_URL || "",
22
- };
23
- } else if (process.env.CI_PIPELINE_ID) {
24
- executor = {
25
- name: "GitLab CI",
26
- type: "gitlab",
27
- buildName: `Pipeline #${process.env.CI_PIPELINE_IID}`,
28
- buildOrder: Number(process.env.CI_PIPELINE_IID) || 1,
29
- buildUrl: process.env.CI_PIPELINE_URL || "",
30
- };
31
- } else if (process.env.BITBUCKET_BUILD_NUMBER) {
32
- executor = {
33
- name: "Bitbucket Pipelines",
34
- type: "bitbucket",
35
- buildName: `Build #${process.env.BITBUCKET_BUILD_NUMBER}`,
36
- buildOrder: Number(process.env.BITBUCKET_BUILD_NUMBER),
37
- buildUrl: process.env.BITBUCKET_BUILD_URL || "",
38
- };
39
- } else if (process.env.CIRCLE_WORKFLOW_ID) {
40
- executor = {
41
- name: "CircleCI",
42
- type: "circleci",
43
- buildName: `Workflow #${process.env.CIRCLE_WORKFLOW_ID}`,
44
- buildOrder: Number(process.env.CIRCLE_BUILD_NUM) || 1,
45
- buildUrl: process.env.CIRCLE_BUILD_URL || "",
46
- };
47
- } else if (process.env.BUILD_BUILDID) {
48
- executor = {
49
- name: "Azure Pipelines",
50
- type: "azure",
51
- buildName: `Build #${process.env.BUILD_BUILDID}`,
52
- buildOrder: Number(process.env.BUILD_BUILDID) || 1,
53
- buildUrl: process.env.BUILD_BUILDURI || "",
54
- };
55
- } else if (process.env.BUILD_NUMBER && process.env.TEAMCITY_VERSION) {
56
- executor = {
57
- name: "TeamCity",
58
- type: "teamcity",
59
- buildName: `Build #${process.env.BUILD_NUMBER}`,
60
- buildOrder: Number(process.env.BUILD_NUMBER) || 1,
61
- buildUrl: process.env.BUILD_URL || "",
62
- };
63
- } else if (process.env.TRAVIS_BUILD_NUMBER) {
64
- executor = {
65
- name: "Travis CI",
66
- type: "travis",
67
- buildName: `Build #${process.env.TRAVIS_BUILD_NUMBER}`,
68
- buildOrder: Number(process.env.TRAVIS_BUILD_NUMBER) || 1,
69
- buildUrl: process.env.TRAVIS_BUILD_WEB_URL || "",
70
- };
71
- } else if (process.env.bamboo_buildNumber) {
72
- executor = {
73
- name: "Bamboo",
74
- type: "bamboo",
75
- buildName: `Build #${process.env.bamboo_buildNumber}`,
76
- buildOrder: Number(process.env.bamboo_buildNumber) || 1,
77
- buildUrl: process.env.bamboo_resultsUrl || "",
78
- };
79
- } else {
80
- executor = {
81
- name: "Local Run",
82
- type: "local",
83
- buildName: "Manual Execution",
84
- buildOrder: 1,
85
- buildUrl: "",
86
- };
87
- }
88
-
89
- if (
90
- fs.existsSync(
91
- path.join(process.cwd(), "node_modules", "artes", "allure-result"),
92
- )
93
- ) {
94
- fs.writeFileSync(
95
- path.join(
96
- process.cwd(),
97
- "node_modules",
98
- "artes",
99
- "allure-result",
100
- "executor.json",
101
- ),
102
- JSON.stringify(executor, null, 2),
103
- );
104
- }
105
-
106
- return executor;
107
- }
108
-
109
- module.exports = { getExecutor };
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ function getExecutor() {
5
+ let executor;
6
+
7
+ if (process.env.GITHUB_RUN_ID) {
8
+ executor = {
9
+ name: "GitHub Actions",
10
+ type: "github",
11
+ buildName: `Workflow #${process.env.GITHUB_RUN_NUMBER}`,
12
+ buildOrder: Number(process.env.GITHUB_RUN_NUMBER),
13
+ buildUrl: `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`,
14
+ };
15
+ } else if (process.env.JENKINS_HOME) {
16
+ executor = {
17
+ name: "Jenkins",
18
+ type: "jenkins",
19
+ buildName: process.env.JOB_NAME || "Manual Run",
20
+ buildOrder: Number(process.env.BUILD_NUMBER) || 1,
21
+ buildUrl: process.env.BUILD_URL || "",
22
+ };
23
+ } else if (process.env.CI_PIPELINE_ID) {
24
+ executor = {
25
+ name: "GitLab CI",
26
+ type: "gitlab",
27
+ buildName: `Pipeline #${process.env.CI_PIPELINE_IID}`,
28
+ buildOrder: Number(process.env.CI_PIPELINE_IID) || 1,
29
+ buildUrl: process.env.CI_PIPELINE_URL || "",
30
+ };
31
+ } else if (process.env.BITBUCKET_BUILD_NUMBER) {
32
+ executor = {
33
+ name: "Bitbucket Pipelines",
34
+ type: "bitbucket",
35
+ buildName: `Build #${process.env.BITBUCKET_BUILD_NUMBER}`,
36
+ buildOrder: Number(process.env.BITBUCKET_BUILD_NUMBER),
37
+ buildUrl: process.env.BITBUCKET_BUILD_URL || "",
38
+ };
39
+ } else if (process.env.CIRCLE_WORKFLOW_ID) {
40
+ executor = {
41
+ name: "CircleCI",
42
+ type: "circleci",
43
+ buildName: `Workflow #${process.env.CIRCLE_WORKFLOW_ID}`,
44
+ buildOrder: Number(process.env.CIRCLE_BUILD_NUM) || 1,
45
+ buildUrl: process.env.CIRCLE_BUILD_URL || "",
46
+ };
47
+ } else if (process.env.BUILD_BUILDID) {
48
+ executor = {
49
+ name: "Azure Pipelines",
50
+ type: "azure",
51
+ buildName: `Build #${process.env.BUILD_BUILDID}`,
52
+ buildOrder: Number(process.env.BUILD_BUILDID) || 1,
53
+ buildUrl: process.env.BUILD_BUILDURI || "",
54
+ };
55
+ } else if (process.env.BUILD_NUMBER && process.env.TEAMCITY_VERSION) {
56
+ executor = {
57
+ name: "TeamCity",
58
+ type: "teamcity",
59
+ buildName: `Build #${process.env.BUILD_NUMBER}`,
60
+ buildOrder: Number(process.env.BUILD_NUMBER) || 1,
61
+ buildUrl: process.env.BUILD_URL || "",
62
+ };
63
+ } else if (process.env.TRAVIS_BUILD_NUMBER) {
64
+ executor = {
65
+ name: "Travis CI",
66
+ type: "travis",
67
+ buildName: `Build #${process.env.TRAVIS_BUILD_NUMBER}`,
68
+ buildOrder: Number(process.env.TRAVIS_BUILD_NUMBER) || 1,
69
+ buildUrl: process.env.TRAVIS_BUILD_WEB_URL || "",
70
+ };
71
+ } else if (process.env.bamboo_buildNumber) {
72
+ executor = {
73
+ name: "Bamboo",
74
+ type: "bamboo",
75
+ buildName: `Build #${process.env.bamboo_buildNumber}`,
76
+ buildOrder: Number(process.env.bamboo_buildNumber) || 1,
77
+ buildUrl: process.env.bamboo_resultsUrl || "",
78
+ };
79
+ } else {
80
+ executor = {
81
+ name: "Local Run",
82
+ type: "local",
83
+ buildName: "Manual Execution",
84
+ buildOrder: 1,
85
+ buildUrl: "",
86
+ };
87
+ }
88
+
89
+ if (
90
+ fs.existsSync(
91
+ path.join(process.cwd(), "node_modules", "artes", "allure-result"),
92
+ )
93
+ ) {
94
+ fs.writeFileSync(
95
+ path.join(
96
+ process.cwd(),
97
+ "node_modules",
98
+ "artes",
99
+ "allure-result",
100
+ "executor.json",
101
+ ),
102
+ JSON.stringify(executor, null, 2),
103
+ );
104
+ }
105
+
106
+ return executor;
107
+ }
108
+
109
+ module.exports = { getExecutor };
@@ -1,83 +1,83 @@
1
- const { addElements } = require("./elementController");
2
- const cucumberConfig = require("../../../cucumber.config");
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { moduleConfig } = require("../../helper/imports/commons");
6
-
7
- const duplicateWarnings = [];
8
- const keyRegistry = {};
9
-
10
- function pomCollector() {
11
- const pomPath = cucumberConfig.default.pomPath;
12
-
13
- if (!fs.existsSync(pomPath)) return;
14
-
15
- fs.readdirSync(pomPath).forEach((file) => {
16
- const filePath = path.join(pomPath, file);
17
-
18
- let parsed;
19
- try {
20
- parsed = JSON.parse(fs.readFileSync(filePath, "utf-8"));
21
- } catch (error) {
22
- console.log(`Error parsing POM file ${file}: ${error.message}`);
23
- return;
24
- }
25
-
26
- Object.keys(parsed).forEach((key) => {
27
- if (keyRegistry[key]) {
28
- duplicateWarnings.push(
29
- `${key} in ${file} has the same key with ${key} in ${keyRegistry[key]}`,
30
- );
31
- } else {
32
- keyRegistry[key] = file;
33
- }
34
- });
35
-
36
- addElements(parsed);
37
- });
38
-
39
- const duplicationFilePath = path.join(
40
- moduleConfig.projectPath,
41
- "node_modules",
42
- "artes",
43
- "pomDuplicateWarnings.json",
44
- );
45
-
46
- if (duplicateWarnings.length > 0) {
47
- fs.mkdirSync(path.dirname(duplicationFilePath), { recursive: true });
48
- fs.writeFileSync(
49
- duplicationFilePath,
50
- JSON.stringify(duplicateWarnings, null, 2),
51
- "utf8",
52
- );
53
- }
54
- }
55
-
56
- function logPomWarnings() {
57
- if (
58
- !fs.existsSync(
59
- path.join(moduleConfig.modulePath, "pomDuplicateWarnings.json"),
60
- )
61
- )
62
- return;
63
-
64
- const duplicateWarnings = JSON.parse(
65
- fs.readFileSync(
66
- path.join(moduleConfig.modulePath, "pomDuplicateWarnings.json"),
67
- "utf8",
68
- ),
69
- );
70
-
71
- console.warn(
72
- "\n\x1b[33m[WARNING] POM DUPLICATE KEY WARNINGS: This may break your tests or cause flaky behavior.",
73
- );
74
-
75
- duplicateWarnings.forEach((warning) => {
76
- console.warn(`- ${warning}`);
77
- });
78
-
79
- console.log("\x1b[0m");
80
- console.log("");
81
- }
82
-
83
- module.exports = { pomCollector, logPomWarnings };
1
+ const { addElements } = require("./elementController");
2
+ const cucumberConfig = require("../../../cucumber.config");
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { moduleConfig } = require("../../helper/imports/commons");
6
+
7
+ const duplicateWarnings = [];
8
+ const keyRegistry = {};
9
+
10
+ function pomCollector() {
11
+ const pomPath = cucumberConfig.default.pomPath;
12
+
13
+ if (!fs.existsSync(pomPath)) return;
14
+
15
+ fs.readdirSync(pomPath).forEach((file) => {
16
+ const filePath = path.join(pomPath, file);
17
+
18
+ let parsed;
19
+ try {
20
+ parsed = JSON.parse(fs.readFileSync(filePath, "utf-8"));
21
+ } catch (error) {
22
+ console.log(`Error parsing POM file ${file}: ${error.message}`);
23
+ return;
24
+ }
25
+
26
+ Object.keys(parsed).forEach((key) => {
27
+ if (keyRegistry[key]) {
28
+ duplicateWarnings.push(
29
+ `${key} in ${file} has the same key with ${key} in ${keyRegistry[key]}`,
30
+ );
31
+ } else {
32
+ keyRegistry[key] = file;
33
+ }
34
+ });
35
+
36
+ addElements(parsed);
37
+ });
38
+
39
+ const duplicationFilePath = path.join(
40
+ moduleConfig.projectPath,
41
+ "node_modules",
42
+ "artes",
43
+ "pomDuplicateWarnings.json",
44
+ );
45
+
46
+ if (duplicateWarnings.length > 0) {
47
+ fs.mkdirSync(path.dirname(duplicationFilePath), { recursive: true });
48
+ fs.writeFileSync(
49
+ duplicationFilePath,
50
+ JSON.stringify(duplicateWarnings, null, 2),
51
+ "utf8",
52
+ );
53
+ }
54
+ }
55
+
56
+ function logPomWarnings() {
57
+ if (
58
+ !fs.existsSync(
59
+ path.join(moduleConfig.modulePath, "pomDuplicateWarnings.json"),
60
+ )
61
+ )
62
+ return;
63
+
64
+ const duplicateWarnings = JSON.parse(
65
+ fs.readFileSync(
66
+ path.join(moduleConfig.modulePath, "pomDuplicateWarnings.json"),
67
+ "utf8",
68
+ ),
69
+ );
70
+
71
+ console.warn(
72
+ "\n\x1b[33m[WARNING] POM DUPLICATE KEY WARNINGS: This may break your tests or cause flaky behavior.",
73
+ );
74
+
75
+ duplicateWarnings.forEach((warning) => {
76
+ console.warn(`- ${warning}`);
77
+ });
78
+
79
+ console.log("\x1b[0m");
80
+ console.log("");
81
+ }
82
+
83
+ module.exports = { pomCollector, logPomWarnings };