@argos-ci/playwright 6.2.0 → 6.3.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/chunk-2ESYSVXG.js +48 -0
- package/dist/fsevents-72LCIACT.node +0 -0
- package/dist/index.d.ts +63 -11
- package/dist/index.js +302 -143
- package/dist/reporter.js +90 -58
- package/dist/test-KJB2UYNA.js +147616 -0
- package/package.json +4 -4
package/dist/reporter.js
CHANGED
|
@@ -1,58 +1,13 @@
|
|
|
1
|
+
import "./chunk-2ESYSVXG.js";
|
|
2
|
+
|
|
1
3
|
// src/reporter.ts
|
|
2
4
|
import chalk from "chalk";
|
|
3
5
|
import { readConfig, upload } from "@argos-ci/core";
|
|
4
6
|
import { copyFile, readdir, writeFile } from "fs/promises";
|
|
5
|
-
import { dirname, join } from "path";
|
|
7
|
+
import { dirname as dirname2, join } from "path";
|
|
6
8
|
|
|
7
9
|
// src/util.ts
|
|
8
|
-
import { createRequire } from "module";
|
|
9
|
-
var require2 = createRequire(import.meta.url);
|
|
10
|
-
var PNG_EXTENSION = `.png`;
|
|
11
|
-
var METADATA_EXTENSION = `.argos.json`;
|
|
12
|
-
var MAX_NAME_LENGTH = 255 - PNG_EXTENSION.length - METADATA_EXTENSION.length;
|
|
13
|
-
function truncate(text, length) {
|
|
14
|
-
if (text.length <= length) {
|
|
15
|
-
return text;
|
|
16
|
-
}
|
|
17
|
-
return text.slice(0, length - 1) + "\u2026";
|
|
18
|
-
}
|
|
19
|
-
function getAutomaticScreenshotName(test, result) {
|
|
20
|
-
const name = test.titlePath().join(" ");
|
|
21
|
-
let suffix = "";
|
|
22
|
-
suffix += result.retry > 0 ? ` #${result.retry + 1}` : "";
|
|
23
|
-
suffix += result.status === "failed" || result.status === "timedOut" ? " (failed)" : "";
|
|
24
|
-
const maxNameLength = MAX_NAME_LENGTH - suffix.length;
|
|
25
|
-
if (name.length > maxNameLength) {
|
|
26
|
-
return `${truncate(`${test.id} - ${test.title}`, maxNameLength)}${suffix}`;
|
|
27
|
-
}
|
|
28
|
-
return `${name}${suffix}`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/attachment.ts
|
|
32
|
-
function getOriginalAttachmentName(name) {
|
|
33
|
-
return name.replace(/^argos\/[^/]+___/, "");
|
|
34
|
-
}
|
|
35
|
-
function getAttachmentFilename(name) {
|
|
36
|
-
if (name.startsWith("argos/screenshot")) {
|
|
37
|
-
return `${getOriginalAttachmentName(name)}${PNG_EXTENSION}`;
|
|
38
|
-
}
|
|
39
|
-
if (name.startsWith("argos/metadata")) {
|
|
40
|
-
return `${getOriginalAttachmentName(name)}${PNG_EXTENSION}${METADATA_EXTENSION}`;
|
|
41
|
-
}
|
|
42
|
-
throw new Error(`Unknown attachment name: ${name}`);
|
|
43
|
-
}
|
|
44
|
-
function checkIsTrace(attachment) {
|
|
45
|
-
return attachment.name === "trace" && attachment.contentType === "application/zip" && Boolean(attachment.path);
|
|
46
|
-
}
|
|
47
|
-
function checkIsArgosScreenshot(attachment) {
|
|
48
|
-
return attachment.name.startsWith("argos/") && attachment.contentType === "image/png" && Boolean(attachment.path);
|
|
49
|
-
}
|
|
50
|
-
function checkIsArgosScreenshotMetadata(attachment) {
|
|
51
|
-
return attachment.name.startsWith("argos/") && attachment.contentType === "application/json" && Boolean(attachment.path);
|
|
52
|
-
}
|
|
53
|
-
function checkIsAutomaticScreenshot(attachment) {
|
|
54
|
-
return attachment.name === "screenshot" && attachment.contentType === "image/png" && Boolean(attachment.path);
|
|
55
|
-
}
|
|
10
|
+
import { createRequire as createRequire2 } from "module";
|
|
56
11
|
|
|
57
12
|
// src/metadata.ts
|
|
58
13
|
import {
|
|
@@ -60,12 +15,12 @@ import {
|
|
|
60
15
|
readVersionFromPackage
|
|
61
16
|
} from "@argos-ci/util";
|
|
62
17
|
import { relative } from "path";
|
|
63
|
-
import { createRequire
|
|
18
|
+
import { createRequire } from "module";
|
|
64
19
|
import { AsyncLocalStorage } from "async_hooks";
|
|
65
|
-
var
|
|
20
|
+
var require2 = createRequire(import.meta.url);
|
|
66
21
|
function tryResolve(pkg) {
|
|
67
22
|
try {
|
|
68
|
-
return
|
|
23
|
+
return require2.resolve(pkg);
|
|
69
24
|
} catch {
|
|
70
25
|
return null;
|
|
71
26
|
}
|
|
@@ -91,7 +46,7 @@ async function getAutomationLibraryMetadata() {
|
|
|
91
46
|
);
|
|
92
47
|
}
|
|
93
48
|
async function getArgosPlaywrightVersion() {
|
|
94
|
-
const pkgPath =
|
|
49
|
+
const pkgPath = require2.resolve("@argos-ci/playwright/package.json");
|
|
95
50
|
return readVersionFromPackage(pkgPath);
|
|
96
51
|
}
|
|
97
52
|
async function getSdkMetadata() {
|
|
@@ -144,6 +99,83 @@ async function getMetadataFromTestCase(testCase, testResult) {
|
|
|
144
99
|
return metadata;
|
|
145
100
|
}
|
|
146
101
|
|
|
102
|
+
// src/util.ts
|
|
103
|
+
import {
|
|
104
|
+
getGlobalScript
|
|
105
|
+
} from "@argos-ci/browser";
|
|
106
|
+
import { dirname, resolve } from "path";
|
|
107
|
+
import { mkdir } from "fs/promises";
|
|
108
|
+
var require3 = createRequire2(import.meta.url);
|
|
109
|
+
var PNG_EXTENSION = `.png`;
|
|
110
|
+
var ARIA_EXTENSION = `.aria.yml`;
|
|
111
|
+
var METADATA_EXTENSION = `.argos.json`;
|
|
112
|
+
var MAX_NAME_LENGTH = 255 - PNG_EXTENSION.length - METADATA_EXTENSION.length;
|
|
113
|
+
function truncate(text, length) {
|
|
114
|
+
if (text.length <= length) {
|
|
115
|
+
return text;
|
|
116
|
+
}
|
|
117
|
+
return text.slice(0, length - 1) + "\u2026";
|
|
118
|
+
}
|
|
119
|
+
function getAutomaticScreenshotName(test, result) {
|
|
120
|
+
const name = test.titlePath().join(" ");
|
|
121
|
+
let suffix = "";
|
|
122
|
+
suffix += result.retry > 0 ? ` #${result.retry + 1}` : "";
|
|
123
|
+
suffix += result.status === "failed" || result.status === "timedOut" ? " (failed)" : "";
|
|
124
|
+
const maxNameLength = MAX_NAME_LENGTH - suffix.length;
|
|
125
|
+
if (name.length > maxNameLength) {
|
|
126
|
+
return `${truncate(`${test.id} - ${test.title}`, maxNameLength)}${suffix}`;
|
|
127
|
+
}
|
|
128
|
+
return `${name}${suffix}`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/attachment.ts
|
|
132
|
+
function parseAttachmentName(name) {
|
|
133
|
+
const match = name.match(/^argos\/(screenshot|aria)(\/metadata)?___(.*)$/);
|
|
134
|
+
if (!match) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const [, mainType, metadataPart, originalName] = match;
|
|
138
|
+
if (!originalName) {
|
|
139
|
+
throw new Error(`Invalid attachment name: ${name}`);
|
|
140
|
+
}
|
|
141
|
+
const type = metadataPart ? `${mainType}/metadata` : mainType;
|
|
142
|
+
return { type, originalName };
|
|
143
|
+
}
|
|
144
|
+
function getAttachmentFilename(attachment) {
|
|
145
|
+
const parsed = parseAttachmentName(attachment.name);
|
|
146
|
+
if (!parsed) {
|
|
147
|
+
throw new Error(`Invalid attachment name: ${attachment.name}`);
|
|
148
|
+
}
|
|
149
|
+
const { type, originalName } = parsed;
|
|
150
|
+
const extension = {
|
|
151
|
+
screenshot: PNG_EXTENSION,
|
|
152
|
+
aria: ARIA_EXTENSION,
|
|
153
|
+
"screenshot/metadata": `${PNG_EXTENSION}${METADATA_EXTENSION}`,
|
|
154
|
+
"aria/metadata": `${ARIA_EXTENSION}${METADATA_EXTENSION}`
|
|
155
|
+
}[type];
|
|
156
|
+
return `${originalName}${extension}`;
|
|
157
|
+
}
|
|
158
|
+
function checkIsTrace(attachment) {
|
|
159
|
+
return attachment.name === "trace" && attachment.contentType === "application/zip" && Boolean(attachment.path);
|
|
160
|
+
}
|
|
161
|
+
function checkIsArgosSnapshot(attachment) {
|
|
162
|
+
const parsed = parseAttachmentName(attachment.name);
|
|
163
|
+
if (!parsed) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return parsed.type === "aria" || parsed.type === "screenshot";
|
|
167
|
+
}
|
|
168
|
+
function checkIsArgosMetadata(attachment) {
|
|
169
|
+
const parsed = parseAttachmentName(attachment.name);
|
|
170
|
+
if (!parsed) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
return parsed.type === "aria/metadata" || parsed.type === "screenshot/metadata";
|
|
174
|
+
}
|
|
175
|
+
function checkIsAutomaticScreenshot(attachment) {
|
|
176
|
+
return attachment.name === "screenshot" && attachment.contentType === "image/png" && Boolean(attachment.path);
|
|
177
|
+
}
|
|
178
|
+
|
|
147
179
|
// src/debug.ts
|
|
148
180
|
import createDebug from "debug";
|
|
149
181
|
var KEY = "@argos-ci/playwright";
|
|
@@ -192,7 +224,7 @@ var ArgosReporter = class {
|
|
|
192
224
|
* Write a file to the temporary directory.
|
|
193
225
|
*/
|
|
194
226
|
async writeFile(path, body) {
|
|
195
|
-
await createDirectory(
|
|
227
|
+
await createDirectory(dirname2(path));
|
|
196
228
|
debug(`Writing file to ${path}`);
|
|
197
229
|
await writeFile(path, body);
|
|
198
230
|
debug(`File written to ${path}`);
|
|
@@ -201,7 +233,7 @@ var ArgosReporter = class {
|
|
|
201
233
|
* Copy a file to the temporary directory.
|
|
202
234
|
*/
|
|
203
235
|
async copyFile(from, to) {
|
|
204
|
-
await createDirectory(
|
|
236
|
+
await createDirectory(dirname2(to));
|
|
205
237
|
debug(`Copying file from ${from} to ${to}`);
|
|
206
238
|
await copyFile(from, to);
|
|
207
239
|
debug(`File copied from ${from} to ${to}`);
|
|
@@ -238,8 +270,8 @@ var ArgosReporter = class {
|
|
|
238
270
|
debug("ArgosReporter:onTestEnd");
|
|
239
271
|
await Promise.all(
|
|
240
272
|
result.attachments.map(async (attachment) => {
|
|
241
|
-
if (
|
|
242
|
-
const path = join(uploadDir, getAttachmentFilename(attachment
|
|
273
|
+
if (checkIsArgosSnapshot(attachment) || checkIsArgosMetadata(attachment)) {
|
|
274
|
+
const path = join(uploadDir, getAttachmentFilename(attachment));
|
|
243
275
|
await Promise.all([
|
|
244
276
|
this.copyFile(attachment.path, path),
|
|
245
277
|
this.copyTraceIfFound(result, path)
|
|
@@ -279,7 +311,7 @@ var ArgosReporter = class {
|
|
|
279
311
|
}
|
|
280
312
|
const buildNameConfig = this.config.buildName;
|
|
281
313
|
const uploadOptions = {
|
|
282
|
-
files: ["**/*.png"],
|
|
314
|
+
files: ["**/*.png", "**/*.aria.yml"],
|
|
283
315
|
parallel: parallel ?? void 0,
|
|
284
316
|
...this.config,
|
|
285
317
|
buildName: void 0,
|