@argos-ci/playwright 7.4.6 → 7.5.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.d.mts +6 -0
- package/dist/index.mjs +20 -3
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -183,6 +183,12 @@ type MetadataConfig = {
|
|
|
183
183
|
test?: ScreenshotMetadata["test"];
|
|
184
184
|
story?: ScreenshotMetadata["story"];
|
|
185
185
|
viewport?: ScreenshotMetadata["viewport"];
|
|
186
|
+
/**
|
|
187
|
+
* Position of the screenshot within its test. Injected by SDKs that drive
|
|
188
|
+
* Playwright without a Playwright test (Vitest), where the counter has to be
|
|
189
|
+
* kept on the side that owns the test context.
|
|
190
|
+
*/
|
|
191
|
+
captureIndex?: number | null;
|
|
186
192
|
};
|
|
187
193
|
/**
|
|
188
194
|
* Set the metadata config.
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
-
import { getGitRepositoryPath, getMetadataPath, getScreenshotName, normalizeBaseNames, readVersionFromPackage, validateThreshold, writeMetadata } from "@argos-ci/util";
|
|
3
|
+
import { getGitRepositoryPath, getMetadataPath, getScreenshotName, getTestRunKey, nextCaptureIndex, normalizeBaseNames, readVersionFromPackage, validateThreshold, writeMetadata } from "@argos-ci/util";
|
|
4
4
|
import { dirname, relative, resolve } from "node:path";
|
|
5
5
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
6
6
|
import { getGlobalScript, resolveViewport } from "@argos-ci/browser";
|
|
@@ -149,6 +149,20 @@ async function getTestInfo() {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
+
* Take the next capture index for the running test, or `null` when the
|
|
153
|
+
* screenshot isn't taken from a test — there is no sequence to record then.
|
|
154
|
+
*/
|
|
155
|
+
function takeCaptureIndex(testInfo) {
|
|
156
|
+
const injected = getMetadataOverrides()?.captureIndex;
|
|
157
|
+
if (injected != null) return injected;
|
|
158
|
+
if (!testInfo) return null;
|
|
159
|
+
return nextCaptureIndex(getTestRunKey({
|
|
160
|
+
id: testInfo.testId,
|
|
161
|
+
retry: testInfo.retry,
|
|
162
|
+
repeat: testInfo.repeatEachIndex
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
152
166
|
* Check if the value is a Page.
|
|
153
167
|
*/
|
|
154
168
|
function checkIsPage(value) {
|
|
@@ -227,7 +241,7 @@ async function prepare(args) {
|
|
|
227
241
|
* Get metadata and path.
|
|
228
242
|
*/
|
|
229
243
|
async function getPathAndMetadata(args) {
|
|
230
|
-
const { handler, testInfo, names, extension, root, useArgosReporter } = args;
|
|
244
|
+
const { handler, testInfo, names, extension, root, useArgosReporter, captureIndex } = args;
|
|
231
245
|
const overrides = getMetadataOverrides();
|
|
232
246
|
const path = useArgosReporter && testInfo ? testInfo.outputPath("argos", `${names.name}${extension}`) : resolve(root, `${names.name}${extension}`);
|
|
233
247
|
const dir = dirname(path);
|
|
@@ -257,6 +271,7 @@ async function getPathAndMetadata(args) {
|
|
|
257
271
|
};
|
|
258
272
|
const viewport = viewportSize ?? getMetadataOverrides()?.viewport;
|
|
259
273
|
if (viewport) metadata.viewport = viewport;
|
|
274
|
+
if (captureIndex != null) metadata.capture = { index: captureIndex };
|
|
260
275
|
metadata.transient = {};
|
|
261
276
|
if (names.baseNames) metadata.transient.baseName = names.baseNames.map((baseName) => `${baseName}${extension}`);
|
|
262
277
|
return {
|
|
@@ -436,6 +451,7 @@ async function argosScreenshot(handler, name, options = {}) {
|
|
|
436
451
|
hasNotText
|
|
437
452
|
}) : element ?? (checkIsFrame(handler) ? handler.locator("body") : handler);
|
|
438
453
|
const testInfo = await getTestInfo();
|
|
454
|
+
const captureIndex = takeCaptureIndex(testInfo);
|
|
439
455
|
const useArgosReporter = checkIsUsingArgosReporter(testInfo);
|
|
440
456
|
await prepare({
|
|
441
457
|
handler,
|
|
@@ -454,7 +470,8 @@ async function argosScreenshot(handler, name, options = {}) {
|
|
|
454
470
|
root,
|
|
455
471
|
names,
|
|
456
472
|
testInfo,
|
|
457
|
-
useArgosReporter
|
|
473
|
+
useArgosReporter,
|
|
474
|
+
captureIndex
|
|
458
475
|
});
|
|
459
476
|
if (options.tag) metadata.tags = Array.isArray(options.tag) ? options.tag : [options.tag];
|
|
460
477
|
if (options.threshold !== void 0) {
|
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": "7.
|
|
4
|
+
"version": "7.5.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@argos-ci/browser": "6.4.5",
|
|
51
|
-
"@argos-ci/core": "6.8.
|
|
52
|
-
"@argos-ci/util": "4.
|
|
51
|
+
"@argos-ci/core": "6.8.3",
|
|
52
|
+
"@argos-ci/util": "4.2.0",
|
|
53
53
|
"chalk": "^6.0.0",
|
|
54
54
|
"debug": "^4.4.3"
|
|
55
55
|
},
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"lint": "eslint .",
|
|
70
70
|
"test": "vitest src"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "b2a9a9d84dc14e148a68295f56cfdfec03f887f1"
|
|
73
73
|
}
|