@argos-ci/playwright 3.0.4 → 3.1.1-alpha.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/reporter.d.ts +19 -0
- package/dist/reporter.mjs +21 -6
- package/package.json +5 -5
package/dist/reporter.d.ts
CHANGED
|
@@ -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
|
@@ -126,7 +126,8 @@ async function getParallelFromConfig(config) {
|
|
|
126
126
|
}
|
|
127
127
|
return {
|
|
128
128
|
total: config.shard.total,
|
|
129
|
-
nonce: argosConfig.parallelNonce
|
|
129
|
+
nonce: argosConfig.parallelNonce,
|
|
130
|
+
index: config.shard.current
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
class ArgosReporter {
|
|
@@ -139,7 +140,9 @@ class ArgosReporter {
|
|
|
139
140
|
this.uploadToArgos = config.uploadToArgos ?? true;
|
|
140
141
|
this.createUploadDirPromise = null;
|
|
141
142
|
}
|
|
142
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Write a file to the temporary directory.
|
|
145
|
+
*/ async writeFile(path, body) {
|
|
143
146
|
const uploadDir = await this.getUploadDir();
|
|
144
147
|
const dir = dirname(path);
|
|
145
148
|
if (dir !== uploadDir) {
|
|
@@ -151,7 +154,9 @@ class ArgosReporter {
|
|
|
151
154
|
await writeFile(path, body);
|
|
152
155
|
debug(`File written to ${path}`);
|
|
153
156
|
}
|
|
154
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Copy a file to the temporary directory.
|
|
159
|
+
*/ async copyFile(from, to) {
|
|
155
160
|
const uploadDir = await this.getUploadDir();
|
|
156
161
|
const dir = dirname(to);
|
|
157
162
|
if (dir !== uploadDir) {
|
|
@@ -163,6 +168,14 @@ class ArgosReporter {
|
|
|
163
168
|
await copyFile(from, to);
|
|
164
169
|
debug(`File copied from ${from} to ${to}`);
|
|
165
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Copy the trace file if found in the result.
|
|
173
|
+
*/ async copyTraceIfFound(result, path) {
|
|
174
|
+
const trace = result.attachments.find(checkIsTrace) ?? null;
|
|
175
|
+
if (trace) {
|
|
176
|
+
await this.copyFile(trace.path, path + ".pw-trace.zip");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
166
179
|
getAutomaticScreenshotName(test, result) {
|
|
167
180
|
let name = test.titlePath().join(" ");
|
|
168
181
|
name += result.retry > 0 ? ` #${result.retry + 1}` : "";
|
|
@@ -185,19 +198,21 @@ class ArgosReporter {
|
|
|
185
198
|
await Promise.all(result.attachments.map(async (attachment)=>{
|
|
186
199
|
if (checkIsArgosScreenshot(attachment) || checkIsArgosScreenshotMetadata(attachment)) {
|
|
187
200
|
const path = join(uploadDir, getAttachmentFilename(attachment.name));
|
|
188
|
-
await
|
|
201
|
+
await Promise.all([
|
|
202
|
+
this.copyFile(attachment.path, path),
|
|
203
|
+
this.copyTraceIfFound(result, path)
|
|
204
|
+
]);
|
|
189
205
|
return;
|
|
190
206
|
}
|
|
191
207
|
// Error screenshots are sent to Argos
|
|
192
208
|
if (checkIsAutomaticScreenshot(attachment)) {
|
|
193
|
-
const trace = result.attachments.find(checkIsTrace) ?? null;
|
|
194
209
|
const metadata = await getMetadataFromTestCase(test, result);
|
|
195
210
|
const name = this.getAutomaticScreenshotName(test, result);
|
|
196
211
|
const path = join(uploadDir, `${name}.png`);
|
|
197
212
|
await Promise.all([
|
|
198
213
|
this.writeFile(path + ".argos.json", JSON.stringify(metadata)),
|
|
199
214
|
this.copyFile(attachment.path, path),
|
|
200
|
-
|
|
215
|
+
this.copyTraceIfFound(result, path)
|
|
201
216
|
]);
|
|
202
217
|
return;
|
|
203
218
|
}
|
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
|
|
4
|
+
"version": "3.1.1-alpha.0+d1a818a",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@argos-ci/browser": "2.1.2",
|
|
46
|
-
"@argos-ci/core": "2.2.
|
|
46
|
+
"@argos-ci/core": "2.2.1-alpha.7+d1a818a",
|
|
47
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": "2.1.
|
|
52
|
+
"@argos-ci/cli": "2.1.1-alpha.7+d1a818a",
|
|
53
53
|
"@argos-ci/playwright": "workspace:.",
|
|
54
54
|
"@playwright/test": "^1.43.0",
|
|
55
55
|
"@types/debug": "^4.1.12",
|
|
@@ -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": "
|
|
64
|
+
"gitHead": "d1a818aeee5bcba93c0492be43704f8c3682222e"
|
|
65
65
|
}
|