artes 1.2.1 → 1.2.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/hooks/hooks.js +26 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -63,14 +63,16 @@ if (fs.existsSync(projectHooksPath)) {
63
63
 
64
64
  /* ------------------- Hooks ------------------- */
65
65
 
66
- BeforeAll(() => {
67
- pomCollector();
68
-
69
- typeof projectHooks.BeforeAll == "function" && projectHooks.BeforeAll()
66
+ BeforeAll(async () => {
67
+ if (typeof projectHooks.BeforeAll === "function") {
68
+ await projectHooks.BeforeAll();
69
+ }
70
70
 
71
+ pomCollector();
71
72
  });
72
73
 
73
74
  Before(async function () {
75
+
74
76
  context.vars = {};
75
77
 
76
78
  const envFilePath = path.join(
@@ -111,26 +113,36 @@ Before(async function () {
111
113
  });
112
114
  }
113
115
 
114
- typeof projectHooks.Before == "function" && projectHooks.Before();
116
+ if (typeof projectHooks.Before === "function") {
117
+ await projectHooks.Before();
118
+ }
115
119
  });
116
120
 
117
- BeforeStep(({ pickleStep }) => {
121
+ BeforeStep(async ({ pickleStep }) => {
118
122
  if (HTTP_METHODS.some((method) => pickleStep.text.includes(method))) {
119
123
  context.response = {};
120
124
  }
121
125
 
122
- typeof projectHooks.BeforeStep == "function" && projectHooks.BeforeStep()
126
+ if (typeof projectHooks.BeforeStep === "function") {
127
+ await projectHooks.BeforeStep();
128
+ }
123
129
  });
124
130
 
125
131
  AfterStep(async function ({ pickleStep }) {
132
+ if (typeof projectHooks.AfterStep === "function") {
133
+ await projectHooks.AfterStep();
134
+ }
135
+
126
136
  if (HTTP_METHODS.some((method) => pickleStep.text.includes(method))) {
127
137
  await attachResponse(this.attach);
128
138
  }
129
-
130
- typeof projectHooks.AfterStep == "function" && projectHooks.AfterStep()
131
139
  });
132
140
 
133
141
  After(async function ({ pickle, result }) {
142
+ if (typeof projectHooks.After === "function") {
143
+ await projectHooks.After();
144
+ }
145
+
134
146
  const shouldReport =
135
147
  (cucumberConfig.default.successReport ||
136
148
  result?.status !== Status.PASSED) &&
@@ -212,10 +224,13 @@ After(async function ({ pickle, result }) {
212
224
  }
213
225
  }
214
226
 
215
- typeof projectHooks.After == "function" && projectHooks.After()
216
227
  });
217
228
 
218
- AfterAll(() => {
229
+ AfterAll(async () => {
230
+ if (typeof projectHooks.AfterAll === "function") {
231
+ await projectHooks.AfterAll();
232
+ }
233
+
219
234
  if (!fs.existsSync(statusDir)) return;
220
235
 
221
236
  const files = fs.readdirSync(statusDir);
@@ -239,6 +254,4 @@ AfterAll(() => {
239
254
  fs.writeFileSync(path.join(process.cwd(), "EXIT_CODE.txt"), "1");
240
255
  }
241
256
  }
242
-
243
- typeof projectHooks.AfterAll == "function" && projectHooks.AfterAll()
244
257
  });