artes 1.0.84 โ 1.0.85
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/cucumber.config.js +17 -14
- package/executer.js +7 -9
- package/package.json +1 -1
- package/src/helper/executers/cleaner.js +6 -10
- package/src/helper/executers/projectCreator.js +1 -1
- package/src/helper/executers/reportGenerator.js +6 -10
- package/src/helper/executers/testRunner.js +2 -4
- package/src/helper/imports/commons.js +2 -1
- package/src/hooks/hooks.js +19 -9
package/cucumber.config.js
CHANGED
|
@@ -20,7 +20,9 @@ module.exports = {
|
|
|
20
20
|
testPercentage: process.env.PERCENTAGE
|
|
21
21
|
? Number(process.env.PERCENTAGE)
|
|
22
22
|
: artesConfig.testPercentage || 0, // number - Percentage of tests to run (0-100)
|
|
23
|
-
timeout:
|
|
23
|
+
timeout: process.env.TIMEOUT
|
|
24
|
+
? Number(process.env.TIMEOUT)
|
|
25
|
+
: artesConfig.timeout || 30, // Default timeout in milliseconds
|
|
24
26
|
paths: process.env.FEATURES
|
|
25
27
|
? [path.join(moduleConfig.projectPath, process.env.FEATURES)]
|
|
26
28
|
: artesConfig.features
|
|
@@ -86,26 +88,27 @@ module.exports = {
|
|
|
86
88
|
worldParameters: artesConfig.worldParameters || {}, // Custom world parameters
|
|
87
89
|
},
|
|
88
90
|
env: process.env.ENV ? JSON.parse(process.env.ENV) : artesConfig.env || "",
|
|
89
|
-
baseURL:
|
|
91
|
+
baseURL: process.env.BASE_URL
|
|
92
|
+
? JSON.parse(process.env.BASE_URL)
|
|
93
|
+
: artesConfig?.baseURL
|
|
94
|
+
? artesConfig?.baseURL
|
|
95
|
+
: "",
|
|
90
96
|
|
|
91
97
|
browser: {
|
|
92
98
|
browserType: process.env.BROWSER
|
|
93
99
|
? JSON.parse(process.env.BROWSER)
|
|
94
100
|
: artesConfig?.browser || "chrome",
|
|
95
101
|
viewport: {
|
|
96
|
-
width:
|
|
97
|
-
process.env.WIDTH
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
? Number(process.env.HEIGHT)
|
|
103
|
-
: artesConfig?.height || 720,
|
|
102
|
+
width: process.env.WIDTH
|
|
103
|
+
? Number(process.env.WIDTH)
|
|
104
|
+
: artesConfig?.width || 1280,
|
|
105
|
+
height: process.env.HEIGHT
|
|
106
|
+
? Number(process.env.HEIGHT)
|
|
107
|
+
: artesConfig?.height || 720,
|
|
104
108
|
},
|
|
105
|
-
maximizeScreen:
|
|
106
|
-
process.env.MAXIMIZE_SCREEN
|
|
107
|
-
|
|
108
|
-
: artesConfig?.maximizeScreen !== undefined
|
|
109
|
+
maximizeScreen: process.env.MAXIMIZE_SCREEN
|
|
110
|
+
? JSON.parse(process.env.MAXIMIZE_SCREEN)
|
|
111
|
+
: artesConfig?.maximizeScreen !== undefined
|
|
109
112
|
? artesConfig.maximizeScreen
|
|
110
113
|
: true,
|
|
111
114
|
headless: process.env.MODE
|
package/executer.js
CHANGED
|
@@ -76,15 +76,13 @@ flags.dryrun ? (process.env.DRYRUN = flags.dryrun) : "";
|
|
|
76
76
|
flags.percentage ? (process.env.PERCENTAGE = percentage) : "";
|
|
77
77
|
|
|
78
78
|
flags.browser && console.log("Running browser:", browser);
|
|
79
|
-
flags.browser
|
|
80
|
-
? (process.env.BROWSER = JSON.stringify(browser))
|
|
81
|
-
: "";
|
|
79
|
+
flags.browser ? (process.env.BROWSER = JSON.stringify(browser)) : "";
|
|
82
80
|
|
|
83
|
-
flags.baseURL
|
|
84
|
-
? (process.env.BASE_URL = JSON.stringify(baseURL))
|
|
85
|
-
: "";
|
|
81
|
+
flags.baseURL ? (process.env.BASE_URL = JSON.stringify(baseURL)) : "";
|
|
86
82
|
|
|
87
|
-
flags.maximizeScreen
|
|
83
|
+
flags.maximizeScreen
|
|
84
|
+
? (process.env.MAXIMIZE_SCREEN = flags.maximizeScreen)
|
|
85
|
+
: "";
|
|
88
86
|
|
|
89
87
|
flags.width && console.log("Running width:", width);
|
|
90
88
|
flags.width ? (process.env.WIDTH = width) : "";
|
|
@@ -99,10 +97,10 @@ function main() {
|
|
|
99
97
|
if (flags.version) return showVersion();
|
|
100
98
|
if (flags.create) return createProject(flags.createYes);
|
|
101
99
|
|
|
102
|
-
|
|
100
|
+
runTests();
|
|
103
101
|
if (flags.report) generateReport();
|
|
104
102
|
cleanUp();
|
|
105
|
-
process.exit(
|
|
103
|
+
process.exit(process.env.EXIT_CODE);
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
main();
|
package/package.json
CHANGED
|
@@ -3,18 +3,14 @@ const { spawnSync } = require("child_process");
|
|
|
3
3
|
|
|
4
4
|
function cleanUp() {
|
|
5
5
|
try {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
stdio: "ignore",
|
|
12
|
-
shell: true,
|
|
13
|
-
},
|
|
14
|
-
);
|
|
6
|
+
spawnSync("npm", ["run", "clean", moduleConfig.cleanUpPaths], {
|
|
7
|
+
cwd: moduleConfig.modulePath,
|
|
8
|
+
stdio: "ignore",
|
|
9
|
+
shell: true,
|
|
10
|
+
});
|
|
15
11
|
} catch (error) {
|
|
16
12
|
console.error("โ Error in cleanup:", error.message);
|
|
17
|
-
process.
|
|
13
|
+
process.env.EXIT_CODE = 1;
|
|
18
14
|
}
|
|
19
15
|
}
|
|
20
16
|
|
|
@@ -40,7 +40,7 @@ function createProject(createYes) {
|
|
|
40
40
|
|
|
41
41
|
// Configuration options:
|
|
42
42
|
// env: "", // string - Environment name for tests
|
|
43
|
-
//testPercentage: 0, // number - Minimum success rate percentage(Default: 0)
|
|
43
|
+
// testPercentage: 0, // number - Minimum success rate percentage(Default: 0)
|
|
44
44
|
// baseURL: "", // string - Base URL for API tests
|
|
45
45
|
// paths: [], // string[] - Paths to feature files
|
|
46
46
|
// steps: "", // string - Step definitions files
|
|
@@ -5,22 +5,18 @@ function generateReport() {
|
|
|
5
5
|
try {
|
|
6
6
|
console.log("๐ Generating report...");
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
stdio: "ignore",
|
|
14
|
-
shell: true,
|
|
15
|
-
},
|
|
16
|
-
);
|
|
8
|
+
spawnSync("npm", ["run", "testWithReport", moduleConfig.reportPath], {
|
|
9
|
+
cwd: moduleConfig.modulePath,
|
|
10
|
+
stdio: "ignore",
|
|
11
|
+
shell: true,
|
|
12
|
+
});
|
|
17
13
|
|
|
18
14
|
console.log(
|
|
19
15
|
`๐ Report generated successfully in ${moduleConfig.reportPath}!`,
|
|
20
16
|
);
|
|
21
17
|
} catch (error) {
|
|
22
18
|
console.error("โ Report generation failed:", error);
|
|
23
|
-
process.
|
|
19
|
+
process.env.EXIT_CODE = 1;
|
|
24
20
|
}
|
|
25
21
|
}
|
|
26
22
|
|
|
@@ -2,13 +2,12 @@ const { spawnSync } = require("child_process");
|
|
|
2
2
|
const { moduleConfig } = require("../imports/commons");
|
|
3
3
|
|
|
4
4
|
function runTests() {
|
|
5
|
-
|
|
6
5
|
try {
|
|
7
6
|
console.log("๐งช Running tests...");
|
|
8
7
|
process.env.FORCE_COLOR = "1";
|
|
9
8
|
process.env.FORCE_STDIO_TTY = "1";
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
spawnSync("cucumber-js", ["--config=cucumber.config.js"], {
|
|
12
11
|
cwd: moduleConfig.modulePath,
|
|
13
12
|
stdio: "inherit",
|
|
14
13
|
shell: true,
|
|
@@ -20,10 +19,9 @@ function runTests() {
|
|
|
20
19
|
},
|
|
21
20
|
});
|
|
22
21
|
console.log("โ
Tests running completed successfully!");
|
|
23
|
-
return result;
|
|
24
22
|
} catch (error) {
|
|
25
23
|
console.error("โ Test execution failed:", error);
|
|
26
|
-
process.
|
|
24
|
+
process.env.EXIT_CODE = 1;
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -30,7 +30,8 @@ const moduleConfig = {
|
|
|
30
30
|
featuresPath: path.join(projectPath, "/tests/features/"),
|
|
31
31
|
stepsPath: path.join(projectPath, "/tests/steps/*.js"),
|
|
32
32
|
pomPath: path.join(projectPath, "/tests/POMs"),
|
|
33
|
-
cleanUpPaths:
|
|
33
|
+
cleanUpPaths:
|
|
34
|
+
"allure-result allure-results test-results @rerun.txt testsStatus",
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
module.exports = {
|
package/src/hooks/hooks.js
CHANGED
|
@@ -17,8 +17,7 @@ const fs = require("fs");
|
|
|
17
17
|
const { moduleConfig } = require("artes/src/helper/imports/commons");
|
|
18
18
|
const path = require("path");
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
let testsFailed = 0;
|
|
20
|
+
const statusDir = path.join(process.cwd(), "testsStatus");
|
|
22
21
|
|
|
23
22
|
setDefaultTimeout(cucumberConfig.default.timeout * 1000);
|
|
24
23
|
|
|
@@ -27,7 +26,6 @@ BeforeAll(async function () {
|
|
|
27
26
|
});
|
|
28
27
|
|
|
29
28
|
Before(async function () {
|
|
30
|
-
totalTests++;
|
|
31
29
|
context.vars = {};
|
|
32
30
|
|
|
33
31
|
const { browser, context: browserContext } = await invokeBrowser();
|
|
@@ -81,7 +79,13 @@ AfterStep(async function ({ pickleStep }) {
|
|
|
81
79
|
|
|
82
80
|
After(async function ({ pickle, result }) {
|
|
83
81
|
if (result?.status != Status.PASSED) {
|
|
84
|
-
|
|
82
|
+
fs.mkdirSync(statusDir, { recursive: true });
|
|
83
|
+
|
|
84
|
+
fs.writeFileSync(
|
|
85
|
+
path.join(statusDir, `${result.status}-${pickle.id}.txt`),
|
|
86
|
+
"",
|
|
87
|
+
);
|
|
88
|
+
|
|
85
89
|
let img = await context.page.screenshot({
|
|
86
90
|
path: `./test-results/visualReport/${pickle.name}/${pickle.name}.png`,
|
|
87
91
|
type: "png",
|
|
@@ -127,21 +131,27 @@ After(async function ({ pickle, result }) {
|
|
|
127
131
|
});
|
|
128
132
|
|
|
129
133
|
AfterAll(async function () {
|
|
130
|
-
const
|
|
134
|
+
const files = fs.readdirSync(statusDir);
|
|
135
|
+
const passedCount = files.filter(
|
|
136
|
+
(file) => file.split("-")[0] === "PASSED",
|
|
137
|
+
).length;
|
|
138
|
+
const totalTests = files.length;
|
|
139
|
+
|
|
140
|
+
const successPercentage = (passedCount / totalTests) * 100;
|
|
131
141
|
const successRate =
|
|
132
|
-
successPercentage.toFixed(2)
|
|
142
|
+
successPercentage.toFixed(2) > cucumberConfig.default.testPercentage;
|
|
133
143
|
|
|
134
|
-
|
|
144
|
+
if (!isNaN(successPercentage)) {
|
|
135
145
|
if (successRate) {
|
|
136
146
|
console.log(
|
|
137
147
|
`Tests passed required ${cucumberConfig.default.testPercentage}% success rate with ${successPercentage.toFixed(2)}% !`,
|
|
138
148
|
);
|
|
139
|
-
process.
|
|
149
|
+
process.env.EXIT_CODE = 0;
|
|
140
150
|
} else {
|
|
141
151
|
console.log(
|
|
142
152
|
`Tests failed at required ${cucumberConfig.default.testPercentage}% success rate with ${successPercentage.toFixed(2)}%!`,
|
|
143
153
|
);
|
|
144
|
-
process.
|
|
154
|
+
process.env.EXIT_CODE = 1;
|
|
145
155
|
}
|
|
146
156
|
}
|
|
147
157
|
});
|