@argos-ci/playwright 1.0.0-alpha.3 → 1.0.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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { mkdir, readFile } from 'node:fs/promises';
2
- import { relative, resolve } from 'node:path';
2
+ import { relative, resolve, dirname } from 'node:path';
3
3
  import { createRequire } from 'node:module';
4
4
  import { resolveViewport } from '@argos-ci/browser';
5
5
  import { getGitRepositoryPath, readVersionFromPackage, getScreenshotName, writeMetadata } from '@argos-ci/util';
@@ -154,6 +154,14 @@ async function argosScreenshot(page, name, { element, has, hasText, viewports, .
154
154
  await page.waitForFunction(()=>window.__ARGOS__.waitForStability());
155
155
  const metadata = await collectMetadata(testInfo);
156
156
  const screenshotPath = useArgosReporter ? null : resolve(screenshotFolder, `${name}.png`);
157
+ if (screenshotPath) {
158
+ const dir = dirname(screenshotPath);
159
+ if (dir !== screenshotFolder) {
160
+ await mkdir(dirname(screenshotPath), {
161
+ recursive: true
162
+ });
163
+ }
164
+ }
157
165
  const [screenshot] = await Promise.all([
158
166
  handle.screenshot({
159
167
  path: screenshotPath ?? undefined,
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult } from "@playwright/test/reporter";
2
3
  import { UploadParameters } from "@argos-ci/core";
3
4
  type ArgosReporterOptions = Omit<UploadParameters, "files" | "root">;
@@ -5,6 +6,7 @@ declare class ArgosReporter implements Reporter {
5
6
  uploadDir: string;
6
7
  config: ArgosReporterOptions;
7
8
  constructor(config: ArgosReporterOptions);
9
+ writeFile(path: string, body: Buffer | string): Promise<void>;
8
10
  onBegin(_config: FullConfig, _suite: Suite): Promise<void>;
9
11
  onTestEnd(test: TestCase, result: TestResult): Promise<void>;
10
12
  onEnd(_result: FullResult): Promise<{
package/dist/reporter.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { upload } from '@argos-ci/core';
2
2
  import { randomBytes } from 'node:crypto';
3
- import { writeFile, copyFile, mkdir } from 'node:fs/promises';
3
+ import { mkdir, writeFile, copyFile } from 'node:fs/promises';
4
4
  import { tmpdir } from 'node:os';
5
- import { relative, join } from 'node:path';
5
+ import { relative, dirname, join } from 'node:path';
6
6
  import { getGitRepositoryPath, readVersionFromPackage } from '@argos-ci/util';
7
7
  import { createRequire } from 'node:module';
8
8
 
@@ -102,6 +102,15 @@ class ArgosReporter {
102
102
  constructor(config){
103
103
  this.config = config;
104
104
  }
105
+ async writeFile(path, body) {
106
+ const dir = dirname(path);
107
+ if (dir !== this.uploadDir) {
108
+ await mkdir(dir, {
109
+ recursive: true
110
+ });
111
+ }
112
+ await writeFile(path, body);
113
+ }
105
114
  async onBegin(_config, _suite) {
106
115
  this.uploadDir = await createTempDirectory();
107
116
  }
@@ -112,7 +121,7 @@ class ArgosReporter {
112
121
  throw new Error("Missing attachment body");
113
122
  }
114
123
  const path = join(this.uploadDir, getAttachementFilename(attachment.name));
115
- await writeFile(path, attachment.body);
124
+ await this.writeFile(path, attachment.body);
116
125
  return;
117
126
  }
118
127
  // Error screenshots are sent to Argos
@@ -121,7 +130,7 @@ class ArgosReporter {
121
130
  const name = test.titlePath().join(" ");
122
131
  const path = join(this.uploadDir, result.status === "failed" || result.status === "timedOut" ? `${name} (failed).png` : `${name}.png`);
123
132
  await Promise.all([
124
- writeFile(path + ".argos.json", JSON.stringify(metadata)),
133
+ this.writeFile(path + ".argos.json", JSON.stringify(metadata)),
125
134
  copyFile(attachment.path, path)
126
135
  ]);
127
136
  }
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.0.0-alpha.3",
4
+ "version": "1.0.0",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -42,12 +42,12 @@
42
42
  "node": ">=16.0.0"
43
43
  },
44
44
  "dependencies": {
45
- "@argos-ci/browser": "1.0.0-alpha.3",
46
- "@argos-ci/core": "1.0.0-alpha.2",
47
- "@argos-ci/util": "1.0.0-alpha.2"
45
+ "@argos-ci/browser": "1.0.0",
46
+ "@argos-ci/core": "1.0.0",
47
+ "@argos-ci/util": "1.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@argos-ci/cli": "1.0.0-alpha.2",
50
+ "@argos-ci/cli": "1.0.0",
51
51
  "@argos-ci/playwright": "workspace:.",
52
52
  "@playwright/test": "^1.38.1",
53
53
  "@types/node": "^16.0.0"
@@ -58,5 +58,5 @@
58
58
  "test": "pnpm exec playwright test",
59
59
  "e2e": "WITH_ARGOS_REPORTER=true pnpm run test"
60
60
  },
61
- "gitHead": "df6e36fccc387245c17bc7f44b8ca81bbe788bd7"
61
+ "gitHead": "f864cced9e48669efab2a35fde612570600b94a7"
62
62
  }