@argos-ci/playwright 1.1.0 → 1.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.mjs +2 -0
- package/dist/reporter.d.ts +1 -0
- package/dist/reporter.mjs +29 -9
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -58,6 +58,8 @@ async function getTestMetadataFromTestInfo(testInfo) {
|
|
|
58
58
|
id: testInfo.testId,
|
|
59
59
|
title: testInfo.title,
|
|
60
60
|
titlePath: testInfo.titlePath,
|
|
61
|
+
retry: testInfo.retry,
|
|
62
|
+
retries: testInfo.project.retries,
|
|
61
63
|
location: {
|
|
62
64
|
file: repositoryPath ? relative(repositoryPath, testInfo.file) : testInfo.file,
|
|
63
65
|
line: testInfo.line,
|
package/dist/reporter.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare class ArgosReporter implements Reporter {
|
|
|
8
8
|
playwrightConfig: FullConfig;
|
|
9
9
|
constructor(config: ArgosReporterOptions);
|
|
10
10
|
writeFile(path: string, body: Buffer | string): Promise<void>;
|
|
11
|
+
getAutomaticScreenshotName(test: TestCase, result: TestResult): string;
|
|
11
12
|
onBegin(config: FullConfig, _suite: Suite): Promise<void>;
|
|
12
13
|
onTestEnd(test: TestCase, result: TestResult): Promise<void>;
|
|
13
14
|
onEnd(_result: FullResult): Promise<{
|
package/dist/reporter.mjs
CHANGED
|
@@ -18,6 +18,15 @@ function getAttachementFilename(name) {
|
|
|
18
18
|
}
|
|
19
19
|
throw new Error(`Unknown attachment name: ${name}`);
|
|
20
20
|
}
|
|
21
|
+
function checkIsTrace(attachment) {
|
|
22
|
+
return attachment.name === "trace" && attachment.contentType === "application/zip" && Boolean(attachment.path);
|
|
23
|
+
}
|
|
24
|
+
function checkIsArgosScreenshot(attachment) {
|
|
25
|
+
return attachment.name.startsWith("argos/") && attachment.contentType === "image/png" && Boolean(attachment.body);
|
|
26
|
+
}
|
|
27
|
+
function checkIsAutomaticScreenshot(attachment) {
|
|
28
|
+
return attachment.name === "screenshot" && attachment.contentType === "image/png" && Boolean(attachment.path);
|
|
29
|
+
}
|
|
21
30
|
|
|
22
31
|
const require = createRequire(import.meta.url);
|
|
23
32
|
const tryResolve = (pkg)=>{
|
|
@@ -63,11 +72,13 @@ async function getLibraryMetadata() {
|
|
|
63
72
|
};
|
|
64
73
|
return metadata;
|
|
65
74
|
}
|
|
66
|
-
async function getTestMetadataFromTestCase(testCase) {
|
|
75
|
+
async function getTestMetadataFromTestCase(testCase, testResult) {
|
|
67
76
|
const repositoryPath = await getGitRepositoryPath();
|
|
68
77
|
const testMetadata = {
|
|
69
78
|
title: testCase.title,
|
|
70
79
|
titlePath: testCase.titlePath(),
|
|
80
|
+
retry: testResult.retry,
|
|
81
|
+
retries: testCase.retries,
|
|
71
82
|
location: {
|
|
72
83
|
file: repositoryPath ? relative(repositoryPath, testCase.location.file) : testCase.location.file,
|
|
73
84
|
line: testCase.location.line,
|
|
@@ -76,10 +87,10 @@ async function getTestMetadataFromTestCase(testCase) {
|
|
|
76
87
|
};
|
|
77
88
|
return testMetadata;
|
|
78
89
|
}
|
|
79
|
-
async function getMetadataFromTestCase(testCase) {
|
|
90
|
+
async function getMetadataFromTestCase(testCase, testResult) {
|
|
80
91
|
const [libMetadata, testMetadata] = await Promise.all([
|
|
81
92
|
getLibraryMetadata(),
|
|
82
|
-
getTestMetadataFromTestCase(testCase)
|
|
93
|
+
getTestMetadataFromTestCase(testCase, testResult)
|
|
83
94
|
]);
|
|
84
95
|
const metadata = {
|
|
85
96
|
test: testMetadata,
|
|
@@ -124,13 +135,19 @@ class ArgosReporter {
|
|
|
124
135
|
}
|
|
125
136
|
await writeFile(path, body);
|
|
126
137
|
}
|
|
138
|
+
getAutomaticScreenshotName(test, result) {
|
|
139
|
+
let name = test.titlePath().join(" ");
|
|
140
|
+
name += result.retry > 0 ? ` #${result.retry + 1}` : "";
|
|
141
|
+
name += result.status === "failed" || result.status === "timedOut" ? " (failed)" : "";
|
|
142
|
+
return name;
|
|
143
|
+
}
|
|
127
144
|
async onBegin(config, _suite) {
|
|
128
145
|
this.playwrightConfig = config;
|
|
129
146
|
this.uploadDir = await createTempDirectory();
|
|
130
147
|
}
|
|
131
148
|
async onTestEnd(test, result) {
|
|
132
149
|
await Promise.all(result.attachments.map(async (attachment)=>{
|
|
133
|
-
if (attachment
|
|
150
|
+
if (checkIsArgosScreenshot(attachment)) {
|
|
134
151
|
if (!attachment.body) {
|
|
135
152
|
throw new Error("Missing attachment body");
|
|
136
153
|
}
|
|
@@ -139,14 +156,17 @@ class ArgosReporter {
|
|
|
139
156
|
return;
|
|
140
157
|
}
|
|
141
158
|
// Error screenshots are sent to Argos
|
|
142
|
-
if (attachment
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
159
|
+
if (checkIsAutomaticScreenshot(attachment)) {
|
|
160
|
+
const trace = result.attachments.find(checkIsTrace) ?? null;
|
|
161
|
+
const metadata = await getMetadataFromTestCase(test, result);
|
|
162
|
+
const name = this.getAutomaticScreenshotName(test, result);
|
|
163
|
+
const path = join(this.uploadDir, `${name}.png`);
|
|
146
164
|
await Promise.all([
|
|
147
165
|
this.writeFile(path + ".argos.json", JSON.stringify(metadata)),
|
|
148
|
-
copyFile(attachment.path, path)
|
|
166
|
+
copyFile(attachment.path, path),
|
|
167
|
+
trace ? copyFile(trace.path, path + ".pw-trace.zip") : null
|
|
149
168
|
]);
|
|
169
|
+
return;
|
|
150
170
|
}
|
|
151
171
|
}));
|
|
152
172
|
}
|
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.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@argos-ci/browser": "1.0.0",
|
|
46
|
-
"@argos-ci/core": "1.
|
|
47
|
-
"@argos-ci/util": "1.
|
|
46
|
+
"@argos-ci/core": "1.2.0",
|
|
47
|
+
"@argos-ci/util": "1.1.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@argos-ci/cli": "1.0.
|
|
50
|
+
"@argos-ci/cli": "1.0.2",
|
|
51
51
|
"@argos-ci/playwright": "workspace:.",
|
|
52
52
|
"@playwright/test": "^1.38.1",
|
|
53
53
|
"@types/node": "^16.0.0"
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"scripts": {
|
|
56
56
|
"prebuild": "rm -rf dist",
|
|
57
57
|
"build": "rollup -c",
|
|
58
|
-
"test": "pnpm exec playwright test
|
|
58
|
+
"test": "pnpm exec playwright test",
|
|
59
59
|
"e2e": "WITH_ARGOS_REPORTER=true pnpm run test"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "47a939474ca0c0d55ca5360dcaa5f8912547ed76"
|
|
62
62
|
}
|