artes 1.1.17 → 1.1.19

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/executer.js CHANGED
@@ -7,6 +7,7 @@ const {
7
7
  generateReport,
8
8
  cleanUp,
9
9
  } = require("./src/helper/executers/exporter");
10
+ const fs = require("fs");
10
11
 
11
12
  const args = process.argv.slice(2);
12
13
 
@@ -111,6 +112,15 @@ function main() {
111
112
 
112
113
  runTests();
113
114
  if (flags.report) generateReport();
115
+
116
+ if (fs.existsSync("./node_modules/artes/testsStatus/EXIT_CODE.txt")) {
117
+ const data = fs.readFileSync(
118
+ "./node_modules/artes/testsStatus/EXIT_CODE.txt",
119
+ "utf8",
120
+ );
121
+ process.env.EXIT_CODE = parseInt(data, 10);
122
+ }
123
+
114
124
  cleanUp();
115
125
  process.exit(process.env.EXIT_CODE);
116
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -13,18 +13,28 @@ function addElements(newElements) {
13
13
  // }
14
14
 
15
15
  function selectorSeperator(element) {
16
- if(typeof element !== "string") return element;
17
-
16
+ if (typeof element !== "string") return element;
17
+
18
18
  const selector = element?.split("=");
19
- const validTypes = ["xpath", "name", "placeholder", "text", "label", "role", "alt", "title", "testid"];
19
+ const validTypes = [
20
+ "xpath",
21
+ "name",
22
+ "placeholder",
23
+ "text",
24
+ "label",
25
+ "role",
26
+ "alt",
27
+ "title",
28
+ "testid",
29
+ ];
20
30
 
21
31
  if (selector && validTypes.includes(selector[0]?.trim())) {
22
32
  return [
23
33
  selector[0].trim(),
24
34
  selector[1] !== undefined ? selector[1].trim() : "",
25
35
  ];
26
- }else{
27
- return selector.join("=")
36
+ } else {
37
+ return selector.join("=");
28
38
  }
29
39
  }
30
40
 
@@ -48,7 +58,7 @@ function getElement(element) {
48
58
  locator = context.page.locator(`xpath=${selector[1]}`, { exact: true });
49
59
  break;
50
60
  case "name":
51
- locator = context.page.locator(`[name="${selector[1]"}]`, {
61
+ locator = context.page.locator(`[name="${selector[1]}"]`, {
52
62
  exact: true,
53
63
  });
54
64
  break;
@@ -86,7 +96,7 @@ function extractVarsFromResponse(responseBody, vars, customVarName) {
86
96
  const keys = path.split(".");
87
97
  let current = obj;
88
98
 
89
- if(typeof obj == 'string') return obj;
99
+ if (typeof obj == "string") return obj;
90
100
 
91
101
  for (const key of keys) {
92
102
  if (current && typeof current === "object" && key in current) {
@@ -243,7 +243,6 @@ const api = {
243
243
 
244
244
  switch (requestDataType) {
245
245
  case "multipart":
246
-
247
246
  const formRequest = processForm(payloadJSON?.body || {});
248
247
 
249
248
  req = await requestMaker(
@@ -38,11 +38,12 @@ Before(async function () {
38
38
 
39
39
  await context.page.setDefaultTimeout(cucumberConfig.default.timeout);
40
40
 
41
- process.env.TRACE && await context.browserContext.tracing.start({
42
- sources: true,
43
- screenshots: true,
44
- snapshots: true,
45
- });
41
+ process.env.TRACE &&
42
+ (await context.browserContext.tracing.start({
43
+ sources: true,
44
+ screenshots: true,
45
+ snapshots: true,
46
+ }));
46
47
  });
47
48
 
48
49
  BeforeStep(async function ({ pickleStep }) {
@@ -93,9 +94,10 @@ After(async function ({ pickle, result }) {
93
94
  "",
94
95
  );
95
96
 
96
- process.env.TRACE && await context.browserContext.tracing.stop({
97
- path: path.join(moduleConfig.projectPath, "./trace.zip"),
98
- });
97
+ process.env.TRACE &&
98
+ (await context.browserContext.tracing.stop({
99
+ path: path.join(moduleConfig.projectPath, "./trace.zip"),
100
+ }));
99
101
 
100
102
  if (context.response) {
101
103
  for (const [key, value] of Object.entries(context.response)) {
@@ -153,12 +155,12 @@ AfterAll(async function () {
153
155
  console.log(
154
156
  `Tests passed required ${cucumberConfig.default.testPercentage}% success rate with ${successPercentage.toFixed(2)}% !`,
155
157
  );
156
- process.env.EXIT_CODE = 0;
158
+ fs.writeFileSync(path.join(statusDir, `EXIT_CODE.txt`), "0");
157
159
  } else {
158
160
  console.log(
159
161
  `Tests failed at required ${cucumberConfig.default.testPercentage}% success rate with ${successPercentage.toFixed(2)}%!`,
160
162
  );
161
- process.env.EXIT_CODE = 1;
163
+ fs.writeFileSync(path.join(statusDir, `EXIT_CODE.txt`), "1");
162
164
  }
163
165
  }
164
166
  }