@argos-ci/playwright 1.9.4-alpha.1 → 3.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 +1 -1
- package/dist/reporter.d.ts +3 -2
- package/dist/reporter.mjs +22 -12
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -181,7 +181,7 @@ async function argosScreenshot(page, name, options = {}) {
|
|
|
181
181
|
const stabilizeAndScreenshot = async (name)=>{
|
|
182
182
|
await page.waitForFunction(()=>window.__ARGOS__.waitForStability());
|
|
183
183
|
const metadata = await collectMetadata(testInfo);
|
|
184
|
-
const nameInProject =
|
|
184
|
+
const nameInProject = testInfo?.project.name ? `${testInfo.project.name}/${name}` : name;
|
|
185
185
|
const screenshotPath = useArgosReporter && testInfo ? testInfo.outputPath("argos", `${nameInProject}.png`) : resolve(screenshotFolder, `${nameInProject}.png`);
|
|
186
186
|
const dir = dirname(screenshotPath);
|
|
187
187
|
if (dir !== screenshotFolder) {
|
package/dist/reporter.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ type ArgosReporterOptions = Omit<UploadParameters, "files" | "root"> & {
|
|
|
9
9
|
uploadToArgos?: boolean;
|
|
10
10
|
};
|
|
11
11
|
declare class ArgosReporter implements Reporter {
|
|
12
|
-
|
|
12
|
+
createUploadDirPromise: null | Promise<string>;
|
|
13
13
|
config: ArgosReporterOptions;
|
|
14
14
|
playwrightConfig: FullConfig;
|
|
15
15
|
uploadToArgos: boolean;
|
|
@@ -17,7 +17,8 @@ declare class ArgosReporter implements Reporter {
|
|
|
17
17
|
writeFile(path: string, body: Buffer | string): Promise<void>;
|
|
18
18
|
copyFile(from: string, to: string): Promise<void>;
|
|
19
19
|
getAutomaticScreenshotName(test: TestCase, result: TestResult): string;
|
|
20
|
-
|
|
20
|
+
getUploadDir(): Promise<string>;
|
|
21
|
+
onBegin(config: FullConfig, _suite: Suite): void;
|
|
21
22
|
onTestEnd(test: TestCase, result: TestResult): Promise<void>;
|
|
22
23
|
onEnd(_result: FullResult): Promise<{
|
|
23
24
|
status: "failed";
|
package/dist/reporter.mjs
CHANGED
|
@@ -107,12 +107,14 @@ async function getMetadataFromTestCase(testCase, testResult) {
|
|
|
107
107
|
const KEY = "@argos-ci/playwright";
|
|
108
108
|
const debug = createDebug(KEY);
|
|
109
109
|
|
|
110
|
-
async function
|
|
110
|
+
async function createUploadDirectory() {
|
|
111
|
+
debug("Creating temporary directory for screenshots");
|
|
111
112
|
const osTmpDirectory = tmpdir();
|
|
112
113
|
const path = join(osTmpDirectory, "argos." + randomBytes(16).toString("hex"));
|
|
113
114
|
await mkdir(path, {
|
|
114
115
|
recursive: true
|
|
115
116
|
});
|
|
117
|
+
debug(`Temporary directory created: ${path}`);
|
|
116
118
|
return path;
|
|
117
119
|
}
|
|
118
120
|
async function getParallelFromConfig(config) {
|
|
@@ -128,17 +130,19 @@ async function getParallelFromConfig(config) {
|
|
|
128
130
|
};
|
|
129
131
|
}
|
|
130
132
|
class ArgosReporter {
|
|
131
|
-
|
|
133
|
+
createUploadDirPromise;
|
|
132
134
|
config;
|
|
133
135
|
playwrightConfig;
|
|
134
136
|
uploadToArgos;
|
|
135
137
|
constructor(config){
|
|
136
138
|
this.config = config;
|
|
137
139
|
this.uploadToArgos = config.uploadToArgos ?? true;
|
|
140
|
+
this.createUploadDirPromise = null;
|
|
138
141
|
}
|
|
139
142
|
async writeFile(path, body) {
|
|
143
|
+
const uploadDir = await this.getUploadDir();
|
|
140
144
|
const dir = dirname(path);
|
|
141
|
-
if (dir !==
|
|
145
|
+
if (dir !== uploadDir) {
|
|
142
146
|
await mkdir(dir, {
|
|
143
147
|
recursive: true
|
|
144
148
|
});
|
|
@@ -148,8 +152,9 @@ class ArgosReporter {
|
|
|
148
152
|
debug(`File written to ${path}`);
|
|
149
153
|
}
|
|
150
154
|
async copyFile(from, to) {
|
|
155
|
+
const uploadDir = await this.getUploadDir();
|
|
151
156
|
const dir = dirname(to);
|
|
152
|
-
if (dir !==
|
|
157
|
+
if (dir !== uploadDir) {
|
|
153
158
|
await mkdir(dir, {
|
|
154
159
|
recursive: true
|
|
155
160
|
});
|
|
@@ -164,18 +169,22 @@ class ArgosReporter {
|
|
|
164
169
|
name += result.status === "failed" || result.status === "timedOut" ? " (failed)" : "";
|
|
165
170
|
return name;
|
|
166
171
|
}
|
|
167
|
-
|
|
172
|
+
getUploadDir() {
|
|
173
|
+
if (!this.createUploadDirPromise) {
|
|
174
|
+
this.createUploadDirPromise = createUploadDirectory();
|
|
175
|
+
}
|
|
176
|
+
return this.createUploadDirPromise;
|
|
177
|
+
}
|
|
178
|
+
onBegin(config, _suite) {
|
|
168
179
|
debug("ArgosReporter:onBegin");
|
|
169
180
|
this.playwrightConfig = config;
|
|
170
|
-
debug(`Creating temporary directory for uploads`);
|
|
171
|
-
this.uploadDir = await createTempDirectory();
|
|
172
|
-
debug(`Temporary directory created for uploads: ${this.uploadDir}`);
|
|
173
181
|
}
|
|
174
182
|
async onTestEnd(test, result) {
|
|
183
|
+
const uploadDir = await this.getUploadDir();
|
|
175
184
|
debug("ArgosReporter:onTestEnd");
|
|
176
185
|
await Promise.all(result.attachments.map(async (attachment)=>{
|
|
177
186
|
if (checkIsArgosScreenshot(attachment) || checkIsArgosScreenshotMetadata(attachment)) {
|
|
178
|
-
const path = join(
|
|
187
|
+
const path = join(uploadDir, getAttachmentFilename(attachment.name));
|
|
179
188
|
await this.copyFile(attachment.path, path);
|
|
180
189
|
return;
|
|
181
190
|
}
|
|
@@ -184,7 +193,7 @@ class ArgosReporter {
|
|
|
184
193
|
const trace = result.attachments.find(checkIsTrace) ?? null;
|
|
185
194
|
const metadata = await getMetadataFromTestCase(test, result);
|
|
186
195
|
const name = this.getAutomaticScreenshotName(test, result);
|
|
187
|
-
const path = join(
|
|
196
|
+
const path = join(uploadDir, `${name}.png`);
|
|
188
197
|
await Promise.all([
|
|
189
198
|
this.writeFile(path + ".argos.json", JSON.stringify(metadata)),
|
|
190
199
|
this.copyFile(attachment.path, path),
|
|
@@ -196,9 +205,10 @@ class ArgosReporter {
|
|
|
196
205
|
}
|
|
197
206
|
async onEnd(_result) {
|
|
198
207
|
debug("ArgosReporter:onEnd");
|
|
208
|
+
const uploadDir = await this.getUploadDir();
|
|
199
209
|
if (!this.uploadToArgos) {
|
|
200
210
|
debug("Not uploading to Argos because uploadToArgos is false.");
|
|
201
|
-
debug(`Upload directory: ${
|
|
211
|
+
debug(`Upload directory: ${uploadDir}`);
|
|
202
212
|
return;
|
|
203
213
|
}
|
|
204
214
|
debug("Getting parallel from config");
|
|
@@ -214,7 +224,7 @@ class ArgosReporter {
|
|
|
214
224
|
files: [
|
|
215
225
|
"**/*.png"
|
|
216
226
|
],
|
|
217
|
-
root:
|
|
227
|
+
root: uploadDir,
|
|
218
228
|
parallel: parallel ?? undefined,
|
|
219
229
|
...this.config
|
|
220
230
|
});
|
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": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
"./package.json": "./package.json"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
42
|
+
"node": ">=18.0.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@argos-ci/browser": "
|
|
46
|
-
"@argos-ci/core": "
|
|
47
|
-
"@argos-ci/util": "
|
|
45
|
+
"@argos-ci/browser": "2.0.0",
|
|
46
|
+
"@argos-ci/core": "2.0.0",
|
|
47
|
+
"@argos-ci/util": "2.0.0",
|
|
48
48
|
"chalk": "^5.3.0",
|
|
49
49
|
"debug": "^4.3.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@argos-ci/cli": "
|
|
52
|
+
"@argos-ci/cli": "2.0.0",
|
|
53
53
|
"@argos-ci/playwright": "workspace:.",
|
|
54
|
-
"@playwright/test": "^1.
|
|
54
|
+
"@playwright/test": "^1.43.0",
|
|
55
55
|
"@types/debug": "^4.1.12",
|
|
56
|
-
"@types/node": "^
|
|
56
|
+
"@types/node": "^18.0.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"prebuild": "rm -rf dist",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"test": "pnpm exec playwright test",
|
|
62
62
|
"e2e": "UPLOAD_TO_ARGOS=true pnpm run test"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "fcadf37f2a9c4a65a3f4c082db56aff2576c8c16"
|
|
65
65
|
}
|