artes 1.2.27 → 1.2.28

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 +22 -31
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.2.27",
3
+ "version": "1.2.28",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,8 @@ const { context } = require("./context");
17
17
  const fs = require("fs");
18
18
  const path = require("path");
19
19
  const { moduleConfig } = require("artes/src/helper/imports/commons");
20
+ require("allure-cucumberjs");
21
+ const allure = require("allure-js-commons");
20
22
 
21
23
  const statusDir = path.join(process.cwd(), "testsStatus");
22
24
  const HTTP_METHODS = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"];
@@ -34,7 +36,7 @@ async function attachResponse(attachFn) {
34
36
  ? `${key}:\n${JSON.stringify(value, null, 2)}`
35
37
  : `${key}:\n${value}`;
36
38
 
37
- await attachFn(text, "text/plain");
39
+ await attachFn(key, text, "text/plain");
38
40
  }
39
41
  }
40
42
 
@@ -132,7 +134,7 @@ AfterStep(async function ({ pickleStep }) {
132
134
  }
133
135
 
134
136
  if (HTTP_METHODS.some((method) => pickleStep.text.includes(method))) {
135
- await attachResponse(this.attach);
137
+ await attachResponse(allure.attachment);
136
138
  }
137
139
  });
138
140
 
@@ -145,25 +147,19 @@ After(async function ({ pickle, result }) {
145
147
  cucumberConfig.default.successReport || result?.status !== Status.PASSED;
146
148
 
147
149
  if (shouldReport & (context.page.url() !== "about:blank")) {
148
- const screenshotPath = path.join(
149
- "test-results",
150
- "visualReport",
151
- pickle.name,
152
- `${pickle.name}.png`,
153
- );
154
150
 
155
- const img = await context.page.screenshot({
156
- path: screenshotPath,
157
- type: "png",
158
- });
151
+ const screenshotBuffer = await context.page.screenshot({ type: "png" });
152
+
153
+ await allure.attachment(
154
+ pickle.name.replaceAll(" ", "_"),
155
+ screenshotBuffer,
156
+ "image/png"
157
+ );
159
158
 
160
- await this.attach(img, {
161
- mediaType: "image/png",
162
- fileName: "Screenshot",
163
- });
164
159
  }
165
160
 
166
161
  saveTestStatus(result, pickle);
162
+
167
163
  if (cucumberConfig.default.reportWithTrace || cucumberConfig.default.trace) {
168
164
  var tracePath = path.join(
169
165
  moduleConfig.projectPath,
@@ -176,17 +172,14 @@ After(async function ({ pickle, result }) {
176
172
  shouldReport &&
177
173
  context.page.url() !== "about:blank"
178
174
  ) {
179
- await context.browserContext.tracing.stop({
175
+
176
+ await context.browserContext.tracing.stop({
180
177
  path: tracePath,
181
178
  });
182
179
 
183
180
  if (cucumberConfig.default.reportWithTrace) {
184
- const trace = fs.readFileSync(tracePath);
185
181
 
186
- await this.attach(trace, {
187
- mediaType: "application/zip",
188
- fileName: "Trace",
189
- });
182
+ await allure.attachTrace("Trace", tracePath);
190
183
 
191
184
  if (!cucumberConfig.default.trace) {
192
185
  spawnSync(
@@ -203,11 +196,13 @@ After(async function ({ pickle, result }) {
203
196
  },
204
197
  );
205
198
  }
199
+
206
200
  }
207
201
  }
208
202
 
209
- await attachResponse(this.attach);
210
-
203
+ await attachResponse(allure.attachment);
204
+ context.response = await {}
205
+
211
206
  await context.page?.close();
212
207
  await context.browserContext?.close();
213
208
  await context.browser?.close();
@@ -224,15 +219,13 @@ After(async function ({ pickle, result }) {
224
219
 
225
220
  await new Promise((resolve) => setTimeout(resolve, 1000));
226
221
 
227
- if (fs.existsSync(videoPath)) {
222
+ if (fs.existsSync(videoPath)) {
228
223
  const webmBuffer = fs.readFileSync(videoPath);
229
- await this.attach(webmBuffer, {
230
- mediaType: "video/webm",
231
- fileName: "Screenrecord",
232
- });
224
+ await allure.attachment("Screenrecord", webmBuffer, "video/webm");
233
225
  }
234
226
  }
235
227
  }
228
+
236
229
  });
237
230
 
238
231
  AfterAll(async () => {
@@ -240,8 +233,6 @@ AfterAll(async () => {
240
233
  await projectHooks.AfterAll();
241
234
  }
242
235
 
243
- logPomWarnings();
244
-
245
236
  if (!fs.existsSync(statusDir)) return;
246
237
 
247
238
  const files = fs.readdirSync(statusDir);