@argos-ci/playwright 6.4.2 → 6.6.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.cjs +4 -4
- package/dist/index.d.mts +185 -0
- package/dist/index.mjs +564 -0
- package/dist/reporter.d.mts +1984 -0
- package/dist/reporter.mjs +323 -0
- package/package.json +14 -14
- package/dist/index.d.ts +0 -158
- package/dist/index.js +0 -600
- package/dist/reporter.d.ts +0 -70
- package/dist/reporter.js +0 -387
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { readConfig, upload } from "@argos-ci/core";
|
|
4
|
+
import { copyFile, readdir, writeFile } from "node:fs/promises";
|
|
5
|
+
import { dirname, join, relative } from "node:path";
|
|
6
|
+
import { createDirectory, createTemporaryDirectory, getGitRepositoryPath, readVersionFromPackage } from "@argos-ci/util";
|
|
7
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
|
+
import "@argos-ci/browser";
|
|
9
|
+
import createDebug from "debug";
|
|
10
|
+
//#region src/metadata.ts
|
|
11
|
+
const require$1 = createRequire(import.meta.url);
|
|
12
|
+
/**
|
|
13
|
+
* Try to resolve a package.
|
|
14
|
+
*/
|
|
15
|
+
function tryResolve(pkg) {
|
|
16
|
+
try {
|
|
17
|
+
return require$1.resolve(pkg);
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Private metadata config storage.
|
|
24
|
+
* Used to inject the metadata from other SDKs like @argos-ci/storybook.
|
|
25
|
+
*/
|
|
26
|
+
const metadataConfigStorage = new AsyncLocalStorage();
|
|
27
|
+
const DEFAULT_PLAYWRIGHT_LIBRARIES = [
|
|
28
|
+
"@playwright/test",
|
|
29
|
+
"playwright",
|
|
30
|
+
"playwright-core"
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Get the name and version of the automation library.
|
|
34
|
+
*/
|
|
35
|
+
async function getAutomationLibraryMetadata() {
|
|
36
|
+
const libraries = metadataConfigStorage.getStore()?.playwrightLibraries ?? DEFAULT_PLAYWRIGHT_LIBRARIES;
|
|
37
|
+
for (const name of libraries) {
|
|
38
|
+
const pkgPath = tryResolve(`${name}/package.json`);
|
|
39
|
+
if (pkgPath) return {
|
|
40
|
+
version: await readVersionFromPackage(pkgPath),
|
|
41
|
+
name
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Unable to find any of the following packages: ${libraries.join(", ")}`);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the version of the Argos Playwright SDK.
|
|
48
|
+
*/
|
|
49
|
+
async function getArgosPlaywrightVersion() {
|
|
50
|
+
return readVersionFromPackage(require$1.resolve("@argos-ci/playwright/package.json"));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get the name and version of the SDK.
|
|
54
|
+
*/
|
|
55
|
+
async function getSdkMetadata() {
|
|
56
|
+
const metadataConfig = metadataConfigStorage.getStore();
|
|
57
|
+
if (metadataConfig) return metadataConfig.sdk;
|
|
58
|
+
return {
|
|
59
|
+
name: "@argos-ci/playwright",
|
|
60
|
+
version: await getArgosPlaywrightVersion()
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the metadata of the automation library and the SDK.
|
|
65
|
+
*/
|
|
66
|
+
async function getLibraryMetadata() {
|
|
67
|
+
const [automationLibrary, sdk] = await Promise.all([getAutomationLibraryMetadata(), getSdkMetadata()]);
|
|
68
|
+
return {
|
|
69
|
+
automationLibrary,
|
|
70
|
+
sdk
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async function getTestMetadataFromTestCase(testCase, testResult) {
|
|
74
|
+
const repositoryPath = await getGitRepositoryPath();
|
|
75
|
+
return {
|
|
76
|
+
title: testCase.title,
|
|
77
|
+
titlePath: testCase.titlePath(),
|
|
78
|
+
tags: testCase.tags.length > 0 ? testCase.tags : void 0,
|
|
79
|
+
retry: testResult.retry,
|
|
80
|
+
retries: testCase.retries,
|
|
81
|
+
repeat: testCase.repeatEachIndex,
|
|
82
|
+
location: {
|
|
83
|
+
file: repositoryPath ? relative(repositoryPath, testCase.location.file) : testCase.location.file,
|
|
84
|
+
line: testCase.location.line,
|
|
85
|
+
column: testCase.location.column
|
|
86
|
+
},
|
|
87
|
+
annotations: testCase.annotations
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async function getMetadataFromTestCase(testCase, testResult) {
|
|
91
|
+
const [libMetadata, testMetadata] = await Promise.all([getLibraryMetadata(), getTestMetadataFromTestCase(testCase, testResult)]);
|
|
92
|
+
return {
|
|
93
|
+
test: testMetadata,
|
|
94
|
+
...libMetadata
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
createRequire(import.meta.url);
|
|
98
|
+
const PNG_EXTENSION = `.png`;
|
|
99
|
+
const ARIA_EXTENSION = `.aria.yml`;
|
|
100
|
+
const METADATA_EXTENSION = `.argos.json`;
|
|
101
|
+
/**
|
|
102
|
+
* Maximum length for a screenshot name.
|
|
103
|
+
*/
|
|
104
|
+
const MAX_NAME_LENGTH = 255 - PNG_EXTENSION.length - METADATA_EXTENSION.length;
|
|
105
|
+
/**
|
|
106
|
+
* Truncate a text to a length and add `...`
|
|
107
|
+
*/
|
|
108
|
+
function truncate(text, length) {
|
|
109
|
+
if (text.length <= length) return text;
|
|
110
|
+
return text.slice(0, length - 1) + "…";
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the automatic screenshot name.
|
|
114
|
+
*/
|
|
115
|
+
function getAutomaticScreenshotName(test, result) {
|
|
116
|
+
const name = test.titlePath().join(" ");
|
|
117
|
+
let suffix = "";
|
|
118
|
+
suffix += result.retry > 0 ? ` #${result.retry + 1}` : "";
|
|
119
|
+
suffix += result.status === "failed" || result.status === "timedOut" ? " (failed)" : "";
|
|
120
|
+
const maxNameLength = MAX_NAME_LENGTH - suffix.length;
|
|
121
|
+
if (name.length > maxNameLength) return `${truncate(`${test.id} - ${test.title}`, maxNameLength)}${suffix}`;
|
|
122
|
+
return `${name}${suffix}`;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/attachment.ts
|
|
126
|
+
function parseAttachmentName(name) {
|
|
127
|
+
const match = name.match(/^argos\/(screenshot|aria)(\/metadata)?___(.*)$/);
|
|
128
|
+
if (!match) return null;
|
|
129
|
+
const [, mainType, metadataPart, originalName] = match;
|
|
130
|
+
if (!originalName) throw new Error(`Invalid attachment name: ${name}`);
|
|
131
|
+
return {
|
|
132
|
+
type: metadataPart ? `${mainType}/metadata` : mainType,
|
|
133
|
+
originalName
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function getAttachmentFilename(attachment) {
|
|
137
|
+
const parsed = parseAttachmentName(attachment.name);
|
|
138
|
+
if (!parsed) throw new Error(`Invalid attachment name: ${attachment.name}`);
|
|
139
|
+
const { type, originalName } = parsed;
|
|
140
|
+
return `${originalName}${{
|
|
141
|
+
screenshot: PNG_EXTENSION,
|
|
142
|
+
aria: ARIA_EXTENSION,
|
|
143
|
+
"screenshot/metadata": `${PNG_EXTENSION}${METADATA_EXTENSION}`,
|
|
144
|
+
"aria/metadata": `${ARIA_EXTENSION}${METADATA_EXTENSION}`
|
|
145
|
+
}[type]}`;
|
|
146
|
+
}
|
|
147
|
+
function checkIsTrace(attachment) {
|
|
148
|
+
return attachment.name === "trace" && attachment.contentType === "application/zip" && Boolean(attachment.path);
|
|
149
|
+
}
|
|
150
|
+
function checkIsArgosSnapshot(attachment) {
|
|
151
|
+
const parsed = parseAttachmentName(attachment.name);
|
|
152
|
+
if (!parsed) return false;
|
|
153
|
+
return parsed.type === "aria" || parsed.type === "screenshot";
|
|
154
|
+
}
|
|
155
|
+
function checkIsArgosMetadata(attachment) {
|
|
156
|
+
const parsed = parseAttachmentName(attachment.name);
|
|
157
|
+
if (!parsed) return false;
|
|
158
|
+
return parsed.type === "aria/metadata" || parsed.type === "screenshot/metadata";
|
|
159
|
+
}
|
|
160
|
+
function checkIsAutomaticScreenshot(attachment) {
|
|
161
|
+
return attachment.name === "screenshot" && attachment.contentType === "image/png" && Boolean(attachment.path);
|
|
162
|
+
}
|
|
163
|
+
const debug = createDebug("@argos-ci/playwright");
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/reporter.ts
|
|
166
|
+
/**
|
|
167
|
+
* Check if the build name is dynamic.
|
|
168
|
+
*/
|
|
169
|
+
function checkIsDynamicBuildName(buildName) {
|
|
170
|
+
return Boolean(typeof buildName === "object" && buildName);
|
|
171
|
+
}
|
|
172
|
+
function createArgosReporterOptions(options) {
|
|
173
|
+
return options;
|
|
174
|
+
}
|
|
175
|
+
async function getParallelFromConfig(config) {
|
|
176
|
+
if (!config.shard) return null;
|
|
177
|
+
if (config.shard.total === 1) return null;
|
|
178
|
+
const argosConfig = await readConfig();
|
|
179
|
+
if (!argosConfig.parallelNonce) throw new Error("Playwright shard mode detected. Please specify ARGOS_PARALLEL_NONCE env variable. Read /parallel-testing");
|
|
180
|
+
return {
|
|
181
|
+
total: argosConfig.parallelTotal ?? config.shard.total,
|
|
182
|
+
nonce: argosConfig.parallelNonce,
|
|
183
|
+
index: argosConfig.parallelIndex ?? config.shard.current
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
var ArgosReporter = class {
|
|
187
|
+
rootUploadDirectoryPromise;
|
|
188
|
+
uploadDirectoryPromises;
|
|
189
|
+
config;
|
|
190
|
+
playwrightConfig;
|
|
191
|
+
uploadToArgos;
|
|
192
|
+
constructor(config) {
|
|
193
|
+
this.config = config;
|
|
194
|
+
this.uploadToArgos = config.uploadToArgos ?? true;
|
|
195
|
+
this.rootUploadDirectoryPromise = null;
|
|
196
|
+
this.uploadDirectoryPromises = /* @__PURE__ */ new Map();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Write a file to the temporary directory.
|
|
200
|
+
*/
|
|
201
|
+
async writeFile(path, body) {
|
|
202
|
+
await createDirectory(dirname(path));
|
|
203
|
+
debug(`Writing file to ${path}`);
|
|
204
|
+
await writeFile(path, body);
|
|
205
|
+
debug(`File written to ${path}`);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Copy a file to the temporary directory.
|
|
209
|
+
*/
|
|
210
|
+
async copyFile(from, to) {
|
|
211
|
+
await createDirectory(dirname(to));
|
|
212
|
+
debug(`Copying file from ${from} to ${to}`);
|
|
213
|
+
await copyFile(from, to);
|
|
214
|
+
debug(`File copied from ${from} to ${to}`);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Copy the trace file if found in the result.
|
|
218
|
+
*/
|
|
219
|
+
async copyTraceIfFound(result, path) {
|
|
220
|
+
const trace = result.attachments.find(checkIsTrace) ?? null;
|
|
221
|
+
if (trace) await this.copyFile(trace.path, path + ".pw-trace.zip");
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get the root upload directory (cached).
|
|
225
|
+
*/
|
|
226
|
+
getRootUploadDirectory() {
|
|
227
|
+
if (!this.rootUploadDirectoryPromise) this.rootUploadDirectoryPromise = createTemporaryDirectory();
|
|
228
|
+
return this.rootUploadDirectoryPromise;
|
|
229
|
+
}
|
|
230
|
+
onBegin(config) {
|
|
231
|
+
debug("ArgosReporter:onBegin");
|
|
232
|
+
this.playwrightConfig = config;
|
|
233
|
+
}
|
|
234
|
+
async onTestEnd(test, result) {
|
|
235
|
+
const buildName = checkIsDynamicBuildName(this.config.buildName) ? this.config.buildName.get(test) : this.config.buildName;
|
|
236
|
+
if (buildName === "") throw new Error("Argos \"buildName\" cannot be an empty string.");
|
|
237
|
+
const rootUploadDir = await this.getRootUploadDirectory();
|
|
238
|
+
const uploadDir = buildName ? join(rootUploadDir, buildName) : rootUploadDir;
|
|
239
|
+
debug("ArgosReporter:onTestEnd");
|
|
240
|
+
await Promise.all(result.attachments.map(async (attachment) => {
|
|
241
|
+
if (checkIsArgosSnapshot(attachment) || checkIsArgosMetadata(attachment)) {
|
|
242
|
+
const path = join(uploadDir, getAttachmentFilename(attachment));
|
|
243
|
+
await Promise.all([this.copyFile(attachment.path, path), this.copyTraceIfFound(result, path)]);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (checkIsAutomaticScreenshot(attachment)) {
|
|
247
|
+
const metadata = await getMetadataFromTestCase(test, result);
|
|
248
|
+
const path = join(uploadDir, `${getAutomaticScreenshotName(test, result)}${PNG_EXTENSION}`);
|
|
249
|
+
await Promise.all([
|
|
250
|
+
this.writeFile(path + METADATA_EXTENSION, JSON.stringify(metadata)),
|
|
251
|
+
this.copyFile(attachment.path, path),
|
|
252
|
+
this.copyTraceIfFound(result, path)
|
|
253
|
+
]);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
async onEnd(result) {
|
|
259
|
+
debug("ArgosReporter:onEnd");
|
|
260
|
+
const rootUploadDir = await this.getRootUploadDirectory();
|
|
261
|
+
if (!this.uploadToArgos) {
|
|
262
|
+
debug("Not uploading to Argos because uploadToArgos is false.");
|
|
263
|
+
debug(`Upload directory: ${rootUploadDir}`);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
debug("Getting parallel from config");
|
|
267
|
+
const parallel = await getParallelFromConfig(this.playwrightConfig);
|
|
268
|
+
if (parallel) debug(`Using parallel config — total: ${parallel.total}, nonce: "${parallel.nonce}"`);
|
|
269
|
+
else debug("Non-parallel mode");
|
|
270
|
+
const buildNameConfig = this.config.buildName;
|
|
271
|
+
const uploadOptions = {
|
|
272
|
+
files: ["**/*.png", "**/*.aria.yml"],
|
|
273
|
+
parallel: parallel ?? void 0,
|
|
274
|
+
...this.config,
|
|
275
|
+
buildName: void 0,
|
|
276
|
+
metadata: { testReport: {
|
|
277
|
+
status: result.status,
|
|
278
|
+
stats: {
|
|
279
|
+
startTime: result.startTime.toISOString(),
|
|
280
|
+
duration: result.duration
|
|
281
|
+
}
|
|
282
|
+
} }
|
|
283
|
+
};
|
|
284
|
+
try {
|
|
285
|
+
if (checkIsDynamicBuildName(buildNameConfig)) {
|
|
286
|
+
debug(`Dynamic build names, uploading to Argos for each build name: ${buildNameConfig.values.join()}`);
|
|
287
|
+
const directories = await readdir(rootUploadDir);
|
|
288
|
+
if (directories.some((dir) => !buildNameConfig.values.includes(dir))) throw new Error(`The \`buildName.values\` (${buildNameConfig.values.join(", ")}) are inconsistent with the \`buildName.get\` returns values (${directories.join(", ")}). Please fix the configuration.`);
|
|
289
|
+
const iteratesOnBuildNames = parallel ? buildNameConfig.values : directories;
|
|
290
|
+
for (const buildName of iteratesOnBuildNames) {
|
|
291
|
+
const uploadDir = join(rootUploadDir, buildName);
|
|
292
|
+
await createDirectory(uploadDir);
|
|
293
|
+
debug(`Uploading to Argos for build: ${buildName}`);
|
|
294
|
+
const res = await upload({
|
|
295
|
+
...uploadOptions,
|
|
296
|
+
root: uploadDir,
|
|
297
|
+
buildName
|
|
298
|
+
});
|
|
299
|
+
console.log(chalk.green(`✅ Argos "${buildName}" build created: ${res.build.url}`));
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
debug("Uploading to Argos");
|
|
303
|
+
const uploadDir = buildNameConfig ? join(rootUploadDir, buildNameConfig) : rootUploadDir;
|
|
304
|
+
const res = await upload({
|
|
305
|
+
...uploadOptions,
|
|
306
|
+
root: uploadDir,
|
|
307
|
+
buildName: buildNameConfig ?? void 0
|
|
308
|
+
});
|
|
309
|
+
console.log(chalk.green(`✅ Argos build created: ${res.build.url}`));
|
|
310
|
+
}
|
|
311
|
+
} catch (error) {
|
|
312
|
+
console.error(chalk.red(`❌ Error while creating the Argos build`));
|
|
313
|
+
console.error(error);
|
|
314
|
+
if (!this.config.ignoreUploadFailures) return { status: "failed" };
|
|
315
|
+
else console.warn(chalk.yellow("⚠️ Upload failure ignored due to ignoreUploadFailures option"));
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
printsToStdio() {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
//#endregion
|
|
323
|
+
export { createArgosReporterOptions, ArgosReporter as default };
|
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.6.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"type": "module",
|
|
31
|
-
"types": "./dist/index.d.
|
|
31
|
+
"types": "./dist/index.d.mts",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
|
-
"types": "./dist/index.d.
|
|
35
|
-
"import": "./dist/index.
|
|
34
|
+
"types": "./dist/index.d.mts",
|
|
35
|
+
"import": "./dist/index.mjs",
|
|
36
36
|
"require": "./dist/index.cjs",
|
|
37
37
|
"default": "./dist/index.cjs"
|
|
38
38
|
},
|
|
39
39
|
"./reporter": {
|
|
40
|
-
"types": "./dist/reporter.d.
|
|
41
|
-
"import": "./dist/reporter.
|
|
42
|
-
"default": "./dist/reporter.
|
|
40
|
+
"types": "./dist/reporter.d.mts",
|
|
41
|
+
"import": "./dist/reporter.mjs",
|
|
42
|
+
"default": "./dist/reporter.mjs"
|
|
43
43
|
},
|
|
44
44
|
"./package.json": "./package.json"
|
|
45
45
|
},
|
|
@@ -47,20 +47,20 @@
|
|
|
47
47
|
"node": ">=20.0.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@argos-ci/browser": "5.1.
|
|
51
|
-
"@argos-ci/core": "5.1.
|
|
52
|
-
"@argos-ci/util": "3.
|
|
50
|
+
"@argos-ci/browser": "5.1.3",
|
|
51
|
+
"@argos-ci/core": "5.1.3",
|
|
52
|
+
"@argos-ci/util": "3.4.0",
|
|
53
53
|
"chalk": "^5.6.2",
|
|
54
54
|
"debug": "^4.4.3"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@playwright/test": "^1.58.
|
|
58
|
-
"@types/debug": "^4.1.
|
|
57
|
+
"@playwright/test": "^1.58.2",
|
|
58
|
+
"@types/debug": "^4.1.13",
|
|
59
59
|
"@types/node": "catalog:",
|
|
60
60
|
"vitest": "catalog:"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
|
-
"build": "
|
|
63
|
+
"build": "tsdown && cp ./src/index.cjs ./dist",
|
|
64
64
|
"test-e2e": "pnpm exec -- playwright test",
|
|
65
65
|
"build-e2e": "playwright install chromium --with-deps",
|
|
66
66
|
"e2e": "UPLOAD_TO_ARGOS=true pnpm run test-e2e",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"lint": "eslint .",
|
|
70
70
|
"test": "vitest src"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "b49d186d5eb6e1338982a4cd5c3cb29e6cb0b7af"
|
|
73
73
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { Locator, Page, Frame, ElementHandle, PageScreenshotOptions, LocatorScreenshotOptions } from '@playwright/test';
|
|
2
|
-
import { StabilizationPluginOptions, ViewportOption } from '@argos-ci/browser';
|
|
3
|
-
import { ScreenshotMetadata } from '@argos-ci/util';
|
|
4
|
-
|
|
5
|
-
type ArgosAttachment = {
|
|
6
|
-
name: string;
|
|
7
|
-
contentType: string;
|
|
8
|
-
path: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type LocatorOptions$1 = Parameters<Page["locator"]>[1];
|
|
12
|
-
type ArgosSnapshotOptions = {
|
|
13
|
-
/**
|
|
14
|
-
* `Locator` or string selector of the element to take a snapshot of.
|
|
15
|
-
*/
|
|
16
|
-
element?: string | Locator;
|
|
17
|
-
/**
|
|
18
|
-
* Folder where the snapshots will be saved if not using the Argos reporter.
|
|
19
|
-
* @default "./screenshots"
|
|
20
|
-
*/
|
|
21
|
-
root?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Wait for the UI to stabilize before taking the snapshot.
|
|
24
|
-
* Set to `false` to disable stabilization.
|
|
25
|
-
* Pass an object to customize the stabilization.
|
|
26
|
-
* @default true
|
|
27
|
-
*/
|
|
28
|
-
stabilize?: boolean | StabilizationPluginOptions;
|
|
29
|
-
/**
|
|
30
|
-
* Maximum time in milliseconds. Defaults to `0` - no timeout
|
|
31
|
-
*/
|
|
32
|
-
timeout?: number;
|
|
33
|
-
} & LocatorOptions$1;
|
|
34
|
-
/**
|
|
35
|
-
* Stabilize the UI and takes a snapshot of the application under test.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* argosAriaSnapshot(page, "my-screenshot")
|
|
39
|
-
* @see https://playwright.dev/docs/aria-snapshots
|
|
40
|
-
*/
|
|
41
|
-
declare function argosAriaSnapshot(
|
|
42
|
-
/**
|
|
43
|
-
* Playwright `page` or `frame` object.
|
|
44
|
-
*/
|
|
45
|
-
handler: Page | Frame,
|
|
46
|
-
/**
|
|
47
|
-
* Name of the snapshot. Must be unique.
|
|
48
|
-
*/
|
|
49
|
-
name: string,
|
|
50
|
-
/**
|
|
51
|
-
* Options for the snapshot.
|
|
52
|
-
*/
|
|
53
|
-
options?: ArgosSnapshotOptions): Promise<ArgosAttachment[]>;
|
|
54
|
-
|
|
55
|
-
type LocatorOptions = Parameters<Page["locator"]>[1];
|
|
56
|
-
type ScreenshotOptions<TBase extends PageScreenshotOptions | LocatorScreenshotOptions> = Omit<TBase, "encoding" | "type" | "omitBackground" | "path">;
|
|
57
|
-
type ArgosScreenshotOptions = {
|
|
58
|
-
/**
|
|
59
|
-
* `Locator` or string selector of the element to take a screenshot of.
|
|
60
|
-
* Passing an `ElementHandle` is discouraged, use a `Locator` instead.
|
|
61
|
-
*/
|
|
62
|
-
element?: string | ElementHandle | Locator;
|
|
63
|
-
/**
|
|
64
|
-
* Viewports to take screenshots of.
|
|
65
|
-
*/
|
|
66
|
-
viewports?: ViewportOption[];
|
|
67
|
-
/**
|
|
68
|
-
* Capture an ARIA snapshot along with the screenshot.
|
|
69
|
-
* Each ARIA snapshot counts as an additional screenshot for billing.
|
|
70
|
-
* When using the viewports setting, one ARIA snapshot is taken per viewport.
|
|
71
|
-
* @see https://playwright.dev/docs/aria-snapshots#aria-snapshots
|
|
72
|
-
* @default false
|
|
73
|
-
*/
|
|
74
|
-
ariaSnapshot?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Custom CSS evaluated during the screenshot process.
|
|
77
|
-
*/
|
|
78
|
-
argosCSS?: string;
|
|
79
|
-
/**
|
|
80
|
-
* Disable hover effects by moving the mouse to the top-left corner of the document.
|
|
81
|
-
* @default true
|
|
82
|
-
*/
|
|
83
|
-
disableHover?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Sensitivity threshold between 0 and 1.
|
|
86
|
-
* The higher the threshold, the less sensitive the diff will be.
|
|
87
|
-
* @default 0.5
|
|
88
|
-
*/
|
|
89
|
-
threshold?: number;
|
|
90
|
-
/**
|
|
91
|
-
* Folder where the screenshots will be saved if not using the Argos reporter.
|
|
92
|
-
* @default "./screenshots"
|
|
93
|
-
*/
|
|
94
|
-
root?: string;
|
|
95
|
-
/**
|
|
96
|
-
* Wait for the UI to stabilize before taking the screenshot.
|
|
97
|
-
* Set to `false` to disable stabilization.
|
|
98
|
-
* Pass an object to customize the stabilization.
|
|
99
|
-
* @default true
|
|
100
|
-
*/
|
|
101
|
-
stabilize?: boolean | StabilizationPluginOptions;
|
|
102
|
-
/**
|
|
103
|
-
* Run a function before taking the screenshot.
|
|
104
|
-
* When using viewports, this function will run before taking sreenshots on each viewport.
|
|
105
|
-
*/
|
|
106
|
-
beforeScreenshot?: (api: {
|
|
107
|
-
/**
|
|
108
|
-
* Run Argos stabilization alorithm.
|
|
109
|
-
* Accepts an object to customize the stabilization.
|
|
110
|
-
* Note that this function is independent of the `stabilize` option.
|
|
111
|
-
*/
|
|
112
|
-
runStabilization: (options?: StabilizationPluginOptions) => Promise<void>;
|
|
113
|
-
}) => Promise<void> | void;
|
|
114
|
-
/**
|
|
115
|
-
* Run a function after taking the screenshot.
|
|
116
|
-
* When using viewports, this function will run after taking sreenshots on each viewport.
|
|
117
|
-
*/
|
|
118
|
-
afterScreenshot?: () => Promise<void> | void;
|
|
119
|
-
} & LocatorOptions & ScreenshotOptions<LocatorScreenshotOptions> & ScreenshotOptions<PageScreenshotOptions>;
|
|
120
|
-
/**
|
|
121
|
-
* Stabilize the UI and takes a screenshot of the application under test.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* argosScreenshot(page, "my-screenshot")
|
|
125
|
-
* @see https://argos-ci.com/docs/playwright#api-overview
|
|
126
|
-
*/
|
|
127
|
-
declare function argosScreenshot(
|
|
128
|
-
/**
|
|
129
|
-
* Playwright `page` or `frame` object.
|
|
130
|
-
*/
|
|
131
|
-
handler: Page | Frame,
|
|
132
|
-
/**
|
|
133
|
-
* Name of the screenshot. Must be unique.
|
|
134
|
-
*/
|
|
135
|
-
name: string,
|
|
136
|
-
/**
|
|
137
|
-
* Options for the screenshot.
|
|
138
|
-
*/
|
|
139
|
-
options?: ArgosScreenshotOptions): Promise<ArgosAttachment[]>;
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Get the CSP script hash.
|
|
143
|
-
*/
|
|
144
|
-
declare function getCSPScriptHash(): string;
|
|
145
|
-
|
|
146
|
-
type MetadataConfig = {
|
|
147
|
-
sdk: ScreenshotMetadata["sdk"];
|
|
148
|
-
playwrightLibraries: string[];
|
|
149
|
-
url?: string;
|
|
150
|
-
test?: ScreenshotMetadata["test"];
|
|
151
|
-
viewport?: ScreenshotMetadata["viewport"];
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Set the metadata config.
|
|
155
|
-
*/
|
|
156
|
-
declare function setMetadataConfig(metadata: MetadataConfig): void;
|
|
157
|
-
|
|
158
|
-
export { type ArgosAttachment, type ArgosScreenshotOptions, type ArgosSnapshotOptions, setMetadataConfig as DO_NOT_USE_setMetadataConfig, type MetadataConfig, argosAriaSnapshot, argosScreenshot, getCSPScriptHash };
|