@argos-ci/playwright 6.1.10 → 6.2.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.js +17 -14
- package/dist/reporter.js +32 -14
- package/package.json +8 -6
package/dist/index.js
CHANGED
|
@@ -12,6 +12,19 @@ import {
|
|
|
12
12
|
writeMetadata
|
|
13
13
|
} from "@argos-ci/util";
|
|
14
14
|
|
|
15
|
+
// src/util.ts
|
|
16
|
+
import { createRequire } from "module";
|
|
17
|
+
var require2 = createRequire(import.meta.url);
|
|
18
|
+
function checkIsUsingArgosReporter(testInfo) {
|
|
19
|
+
const reporterPath = require2.resolve("@argos-ci/playwright/reporter");
|
|
20
|
+
return testInfo.config.reporter.some(
|
|
21
|
+
(reporter) => reporter[0].includes("@argos-ci/playwright/reporter") || reporter[0] === reporterPath
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
var PNG_EXTENSION = `.png`;
|
|
25
|
+
var METADATA_EXTENSION = `.argos.json`;
|
|
26
|
+
var MAX_NAME_LENGTH = 255 - PNG_EXTENSION.length - METADATA_EXTENSION.length;
|
|
27
|
+
|
|
15
28
|
// src/attachment.ts
|
|
16
29
|
function getAttachmentName(name, type) {
|
|
17
30
|
return `argos/${type}___${name}`;
|
|
@@ -23,12 +36,12 @@ import {
|
|
|
23
36
|
readVersionFromPackage
|
|
24
37
|
} from "@argos-ci/util";
|
|
25
38
|
import { relative } from "path";
|
|
26
|
-
import { createRequire } from "module";
|
|
39
|
+
import { createRequire as createRequire2 } from "module";
|
|
27
40
|
import { AsyncLocalStorage } from "async_hooks";
|
|
28
|
-
var
|
|
41
|
+
var require3 = createRequire2(import.meta.url);
|
|
29
42
|
function tryResolve(pkg) {
|
|
30
43
|
try {
|
|
31
|
-
return
|
|
44
|
+
return require3.resolve(pkg);
|
|
32
45
|
} catch {
|
|
33
46
|
return null;
|
|
34
47
|
}
|
|
@@ -60,7 +73,7 @@ async function getAutomationLibraryMetadata() {
|
|
|
60
73
|
);
|
|
61
74
|
}
|
|
62
75
|
async function getArgosPlaywrightVersion() {
|
|
63
|
-
const pkgPath =
|
|
76
|
+
const pkgPath = require3.resolve("@argos-ci/playwright/package.json");
|
|
64
77
|
return readVersionFromPackage(pkgPath);
|
|
65
78
|
}
|
|
66
79
|
async function getSdkMetadata() {
|
|
@@ -126,16 +139,6 @@ async function getTestMetadata(testInfo) {
|
|
|
126
139
|
return testMetadata;
|
|
127
140
|
}
|
|
128
141
|
|
|
129
|
-
// src/util.ts
|
|
130
|
-
import { createRequire as createRequire2 } from "module";
|
|
131
|
-
var require3 = createRequire2(import.meta.url);
|
|
132
|
-
function checkIsUsingArgosReporter(testInfo) {
|
|
133
|
-
const reporterPath = require3.resolve("@argos-ci/playwright/reporter");
|
|
134
|
-
return testInfo.config.reporter.some(
|
|
135
|
-
(reporter) => reporter[0].includes("@argos-ci/playwright/reporter") || reporter[0] === reporterPath
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
142
|
// src/screenshot.ts
|
|
140
143
|
var DEFAULT_SCREENSHOT_ROOT = "./screenshots";
|
|
141
144
|
async function injectArgos(handler) {
|
package/dist/reporter.js
CHANGED
|
@@ -4,16 +4,40 @@ import { readConfig, upload } from "@argos-ci/core";
|
|
|
4
4
|
import { copyFile, readdir, writeFile } from "fs/promises";
|
|
5
5
|
import { dirname, join } from "path";
|
|
6
6
|
|
|
7
|
+
// 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
|
+
|
|
7
31
|
// src/attachment.ts
|
|
8
32
|
function getOriginalAttachmentName(name) {
|
|
9
33
|
return name.replace(/^argos\/[^/]+___/, "");
|
|
10
34
|
}
|
|
11
35
|
function getAttachmentFilename(name) {
|
|
12
36
|
if (name.startsWith("argos/screenshot")) {
|
|
13
|
-
return `${getOriginalAttachmentName(name)}
|
|
37
|
+
return `${getOriginalAttachmentName(name)}${PNG_EXTENSION}`;
|
|
14
38
|
}
|
|
15
39
|
if (name.startsWith("argos/metadata")) {
|
|
16
|
-
return `${getOriginalAttachmentName(name)}
|
|
40
|
+
return `${getOriginalAttachmentName(name)}${PNG_EXTENSION}${METADATA_EXTENSION}`;
|
|
17
41
|
}
|
|
18
42
|
throw new Error(`Unknown attachment name: ${name}`);
|
|
19
43
|
}
|
|
@@ -36,12 +60,12 @@ import {
|
|
|
36
60
|
readVersionFromPackage
|
|
37
61
|
} from "@argos-ci/util";
|
|
38
62
|
import { relative } from "path";
|
|
39
|
-
import { createRequire } from "module";
|
|
63
|
+
import { createRequire as createRequire2 } from "module";
|
|
40
64
|
import { AsyncLocalStorage } from "async_hooks";
|
|
41
|
-
var
|
|
65
|
+
var require3 = createRequire2(import.meta.url);
|
|
42
66
|
function tryResolve(pkg) {
|
|
43
67
|
try {
|
|
44
|
-
return
|
|
68
|
+
return require3.resolve(pkg);
|
|
45
69
|
} catch {
|
|
46
70
|
return null;
|
|
47
71
|
}
|
|
@@ -67,7 +91,7 @@ async function getAutomationLibraryMetadata() {
|
|
|
67
91
|
);
|
|
68
92
|
}
|
|
69
93
|
async function getArgosPlaywrightVersion() {
|
|
70
|
-
const pkgPath =
|
|
94
|
+
const pkgPath = require3.resolve("@argos-ci/playwright/package.json");
|
|
71
95
|
return readVersionFromPackage(pkgPath);
|
|
72
96
|
}
|
|
73
97
|
async function getSdkMetadata() {
|
|
@@ -152,12 +176,6 @@ async function getParallelFromConfig(config) {
|
|
|
152
176
|
index: argosConfig.parallelIndex ?? config.shard.current
|
|
153
177
|
};
|
|
154
178
|
}
|
|
155
|
-
function getAutomaticScreenshotName(test, result) {
|
|
156
|
-
let name = test.titlePath().join(" ");
|
|
157
|
-
name += result.retry > 0 ? ` #${result.retry + 1}` : "";
|
|
158
|
-
name += result.status === "failed" || result.status === "timedOut" ? " (failed)" : "";
|
|
159
|
-
return name;
|
|
160
|
-
}
|
|
161
179
|
var ArgosReporter = class {
|
|
162
180
|
rootUploadDirectoryPromise;
|
|
163
181
|
uploadDirectoryPromises;
|
|
@@ -231,9 +249,9 @@ var ArgosReporter = class {
|
|
|
231
249
|
if (checkIsAutomaticScreenshot(attachment)) {
|
|
232
250
|
const metadata = await getMetadataFromTestCase(test, result);
|
|
233
251
|
const name = getAutomaticScreenshotName(test, result);
|
|
234
|
-
const path = join(uploadDir, `${name}
|
|
252
|
+
const path = join(uploadDir, `${name}${PNG_EXTENSION}`);
|
|
235
253
|
await Promise.all([
|
|
236
|
-
this.writeFile(path +
|
|
254
|
+
this.writeFile(path + METADATA_EXTENSION, JSON.stringify(metadata)),
|
|
237
255
|
this.copyFile(attachment.path, path),
|
|
238
256
|
this.copyTraceIfFound(result, path)
|
|
239
257
|
]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/playwright",
|
|
3
3
|
"description": "Playwright SDK for visual testing with Argos.",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.2.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -48,15 +48,16 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@argos-ci/browser": "5.0.0",
|
|
51
|
-
"@argos-ci/core": "4.
|
|
51
|
+
"@argos-ci/core": "4.4.0",
|
|
52
52
|
"@argos-ci/util": "3.1.1",
|
|
53
53
|
"chalk": "^5.6.2",
|
|
54
54
|
"debug": "^4.4.3"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@playwright/test": "^1.
|
|
57
|
+
"@playwright/test": "^1.56.1",
|
|
58
58
|
"@types/debug": "^4.1.12",
|
|
59
|
-
"@types/node": "catalog:"
|
|
59
|
+
"@types/node": "catalog:",
|
|
60
|
+
"vitest": "catalog:"
|
|
60
61
|
},
|
|
61
62
|
"scripts": {
|
|
62
63
|
"build": "tsup && cp ./src/index.cjs ./dist",
|
|
@@ -65,7 +66,8 @@
|
|
|
65
66
|
"e2e": "UPLOAD_TO_ARGOS=true pnpm run test-e2e",
|
|
66
67
|
"check-types": "tsc",
|
|
67
68
|
"check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
|
|
68
|
-
"lint": "eslint ."
|
|
69
|
+
"lint": "eslint .",
|
|
70
|
+
"test": "vitest src"
|
|
69
71
|
},
|
|
70
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "7b770d9d0c621980319bd5a195413f96c54d5752"
|
|
71
73
|
}
|