@argos-ci/playwright 1.6.1 → 1.6.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.
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { mkdir, readFile } from 'node:fs/promises';
2
2
  import { relative, resolve, dirname } from 'node:path';
3
3
  import { createRequire } from 'node:module';
4
4
  import { resolveViewport } from '@argos-ci/browser';
5
- import { getGitRepositoryPath, readVersionFromPackage, getScreenshotName, writeMetadata } from '@argos-ci/util';
5
+ import { getGitRepositoryPath, readVersionFromPackage, getScreenshotName, writeMetadata, getMetadataPath } from '@argos-ci/util';
6
6
 
7
7
  function getAttachmentName(name, type) {
8
8
  return `argos/${type}___${name}`;
@@ -173,7 +173,7 @@ async function argosScreenshot(page, name, { element, has, hasText, viewports, a
173
173
  });
174
174
  }
175
175
  }
176
- const [screenshot] = await Promise.all([
176
+ await Promise.all([
177
177
  handle.screenshot({
178
178
  path: screenshotPath ?? undefined,
179
179
  type: "png",
@@ -189,11 +189,11 @@ async function argosScreenshot(page, name, { element, has, hasText, viewports, a
189
189
  if (useArgosReporter) {
190
190
  await Promise.all([
191
191
  testInfo.attach(getAttachmentName(name, "metadata"), {
192
- body: JSON.stringify(metadata),
192
+ path: getMetadataPath(screenshotPath),
193
193
  contentType: "application/json"
194
194
  }),
195
195
  testInfo.attach(getAttachmentName(name, "screenshot"), {
196
- body: screenshot,
196
+ path: screenshotPath,
197
197
  contentType: "image/png"
198
198
  })
199
199
  ]);
@@ -15,6 +15,7 @@ declare class ArgosReporter implements Reporter {
15
15
  uploadToArgos: boolean;
16
16
  constructor(config: ArgosReporterOptions);
17
17
  writeFile(path: string, body: Buffer | string): Promise<void>;
18
+ copyFile(from: string, to: string): Promise<void>;
18
19
  getAutomaticScreenshotName(test: TestCase, result: TestResult): string;
19
20
  onBegin(config: FullConfig, _suite: Suite): Promise<void>;
20
21
  onTestEnd(test: TestCase, result: TestResult): Promise<void>;
package/dist/reporter.mjs CHANGED
@@ -141,6 +141,15 @@ class ArgosReporter {
141
141
  }
142
142
  await writeFile(path, body);
143
143
  }
144
+ async copyFile(from, to) {
145
+ const dir = dirname(to);
146
+ if (dir !== this.uploadDir) {
147
+ await mkdir(dir, {
148
+ recursive: true
149
+ });
150
+ }
151
+ await copyFile(from, to);
152
+ }
144
153
  getAutomaticScreenshotName(test, result) {
145
154
  let name = test.titlePath().join(" ");
146
155
  name += result.retry > 0 ? ` #${result.retry + 1}` : "";
@@ -155,7 +164,7 @@ class ArgosReporter {
155
164
  await Promise.all(result.attachments.map(async (attachment)=>{
156
165
  if (checkIsArgosScreenshot(attachment) || checkIsArgosScreenshotMetadata(attachment)) {
157
166
  const path = join(this.uploadDir, getAttachmentFilename(attachment.name));
158
- await copyFile(attachment.path, path);
167
+ await this.copyFile(attachment.path, path);
159
168
  return;
160
169
  }
161
170
  // Error screenshots are sent to Argos
@@ -166,8 +175,8 @@ class ArgosReporter {
166
175
  const path = join(this.uploadDir, `${name}.png`);
167
176
  await Promise.all([
168
177
  this.writeFile(path + ".argos.json", JSON.stringify(metadata)),
169
- copyFile(attachment.path, path),
170
- trace ? copyFile(trace.path, path + ".pw-trace.zip") : null
178
+ this.copyFile(attachment.path, path),
179
+ trace ? this.copyFile(trace.path, path + ".pw-trace.zip") : null
171
180
  ]);
172
181
  return;
173
182
  }
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": "1.6.1",
4
+ "version": "1.6.3",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -59,5 +59,5 @@
59
59
  "test": "pnpm exec playwright test",
60
60
  "e2e": "UPLOAD_TO_ARGOS=true pnpm run test"
61
61
  },
62
- "gitHead": "b601673bab3248f9a615ded0cca76af78830eeec"
62
+ "gitHead": "b89289d745507679cc68b35dafb7ac5e6cbd6dda"
63
63
  }