@argos-ci/playwright 3.0.3 → 3.1.0

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.
@@ -14,8 +14,27 @@ declare class ArgosReporter implements Reporter {
14
14
  playwrightConfig: FullConfig;
15
15
  uploadToArgos: boolean;
16
16
  constructor(config: ArgosReporterOptions);
17
+ /**
18
+ * Write a file to the temporary directory.
19
+ */
20
+ /**
21
+ * Write a file to the temporary directory.
22
+ */
17
23
  writeFile(path: string, body: Buffer | string): Promise<void>;
24
+ /**
25
+ * Copy a file to the temporary directory.
26
+ */
27
+ /**
28
+ * Copy a file to the temporary directory.
29
+ */
18
30
  copyFile(from: string, to: string): Promise<void>;
31
+ /**
32
+ * Copy the trace file if found in the result.
33
+ */
34
+ /**
35
+ * Copy the trace file if found in the result.
36
+ */
37
+ copyTraceIfFound(result: TestResult, path: string): Promise<void>;
19
38
  getAutomaticScreenshotName(test: TestCase, result: TestResult): string;
20
39
  getUploadDir(): Promise<string>;
21
40
  onBegin(config: FullConfig, _suite: Suite): void;
package/dist/reporter.mjs CHANGED
@@ -139,7 +139,9 @@ class ArgosReporter {
139
139
  this.uploadToArgos = config.uploadToArgos ?? true;
140
140
  this.createUploadDirPromise = null;
141
141
  }
142
- async writeFile(path, body) {
142
+ /**
143
+ * Write a file to the temporary directory.
144
+ */ async writeFile(path, body) {
143
145
  const uploadDir = await this.getUploadDir();
144
146
  const dir = dirname(path);
145
147
  if (dir !== uploadDir) {
@@ -151,7 +153,9 @@ class ArgosReporter {
151
153
  await writeFile(path, body);
152
154
  debug(`File written to ${path}`);
153
155
  }
154
- async copyFile(from, to) {
156
+ /**
157
+ * Copy a file to the temporary directory.
158
+ */ async copyFile(from, to) {
155
159
  const uploadDir = await this.getUploadDir();
156
160
  const dir = dirname(to);
157
161
  if (dir !== uploadDir) {
@@ -163,6 +167,14 @@ class ArgosReporter {
163
167
  await copyFile(from, to);
164
168
  debug(`File copied from ${from} to ${to}`);
165
169
  }
170
+ /**
171
+ * Copy the trace file if found in the result.
172
+ */ async copyTraceIfFound(result, path) {
173
+ const trace = result.attachments.find(checkIsTrace) ?? null;
174
+ if (trace) {
175
+ await this.copyFile(trace.path, path + ".pw-trace.zip");
176
+ }
177
+ }
166
178
  getAutomaticScreenshotName(test, result) {
167
179
  let name = test.titlePath().join(" ");
168
180
  name += result.retry > 0 ? ` #${result.retry + 1}` : "";
@@ -185,19 +197,21 @@ class ArgosReporter {
185
197
  await Promise.all(result.attachments.map(async (attachment)=>{
186
198
  if (checkIsArgosScreenshot(attachment) || checkIsArgosScreenshotMetadata(attachment)) {
187
199
  const path = join(uploadDir, getAttachmentFilename(attachment.name));
188
- await this.copyFile(attachment.path, path);
200
+ await Promise.all([
201
+ this.copyFile(attachment.path, path),
202
+ this.copyTraceIfFound(result, path)
203
+ ]);
189
204
  return;
190
205
  }
191
206
  // Error screenshots are sent to Argos
192
207
  if (checkIsAutomaticScreenshot(attachment)) {
193
- const trace = result.attachments.find(checkIsTrace) ?? null;
194
208
  const metadata = await getMetadataFromTestCase(test, result);
195
209
  const name = this.getAutomaticScreenshotName(test, result);
196
210
  const path = join(uploadDir, `${name}.png`);
197
211
  await Promise.all([
198
212
  this.writeFile(path + ".argos.json", JSON.stringify(metadata)),
199
213
  this.copyFile(attachment.path, path),
200
- trace ? this.copyFile(trace.path, path + ".pw-trace.zip") : null
214
+ this.copyTraceIfFound(result, path)
201
215
  ]);
202
216
  return;
203
217
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/playwright",
3
3
  "description": "Visual testing solution to avoid visual regression. Playwright commands and utilities for Argos visual testing.",
4
- "version": "3.0.3",
4
+ "version": "3.1.0",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -42,7 +42,7 @@
42
42
  "node": ">=18.0.0"
43
43
  },
44
44
  "dependencies": {
45
- "@argos-ci/browser": "2.1.1",
45
+ "@argos-ci/browser": "2.1.2",
46
46
  "@argos-ci/core": "2.2.0",
47
47
  "@argos-ci/util": "2.0.0",
48
48
  "chalk": "^5.3.0",
@@ -58,8 +58,8 @@
58
58
  "scripts": {
59
59
  "prebuild": "rm -rf dist",
60
60
  "build": "rollup -c",
61
- "test": "pnpm exec playwright test",
61
+ "test": "pnpm exec -- playwright test",
62
62
  "e2e": "UPLOAD_TO_ARGOS=true pnpm run test"
63
63
  },
64
- "gitHead": "f2c984da3cf1da7e88dce8c0e90870133da4aae5"
64
+ "gitHead": "ee9a8f3dbfdf57820a81b598eb33d95e23968c81"
65
65
  }