@argos-ci/playwright 3.7.1 → 3.8.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 +14 -1
- package/dist/index.d.ts +15 -8
- package/dist/index.mjs +63 -25
- package/dist/reporter.mjs +45 -19
- package/package.json +16 -11
package/dist/index.cjs
CHANGED
|
@@ -4,5 +4,18 @@ const argosScreenshot = async (...args)=>{
|
|
|
4
4
|
const { argosScreenshot } = await import('./index.mjs');
|
|
5
5
|
return argosScreenshot(...args);
|
|
6
6
|
};
|
|
7
|
-
// @ts-ignore
|
|
8
7
|
exports.argosScreenshot = argosScreenshot;
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
const getCSPScriptHash = async (...args)=>{
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
const { getCSPScriptHash } = await import('./index.mjs');
|
|
12
|
+
return getCSPScriptHash(...args);
|
|
13
|
+
};
|
|
14
|
+
exports.getCSPScriptHash = getCSPScriptHash;
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
const DO_NOT_USE_setMetadataConfig = async (...args)=>{
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const { DO_NOT_USE_setMetadataConfig } = await import('./index.mjs');
|
|
19
|
+
return DO_NOT_USE_setMetadataConfig(...args);
|
|
20
|
+
};
|
|
21
|
+
exports.DO_NOT_USE_setMetadataConfig = DO_NOT_USE_setMetadataConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Page, PageScreenshotOptions, LocatorScreenshotOptions, ElementHandle, Locator } from "@playwright/test";
|
|
2
2
|
import { ViewportOption } from "@argos-ci/browser";
|
|
3
|
+
import { ScreenshotMetadata } from "@argos-ci/util";
|
|
3
4
|
type LocatorOptions = Parameters<Page["locator"]>[1];
|
|
4
5
|
type ScreenshotOptions<TBase extends PageScreenshotOptions | LocatorScreenshotOptions> = Omit<TBase, "encoding" | "type" | "omitBackground" | "path">;
|
|
5
6
|
type ArgosScreenshotOptions = {
|
|
@@ -40,21 +41,27 @@ type ArgosScreenshotOptions = {
|
|
|
40
41
|
* argosScreenshot(page, "my-screenshot")
|
|
41
42
|
* @see https://argos-ci.com/docs/playwright#api-overview
|
|
42
43
|
*/
|
|
43
|
-
declare function argosScreenshot(
|
|
44
|
-
/**
|
|
44
|
+
declare function argosScreenshot(/**
|
|
45
45
|
* Playwright `page` object.
|
|
46
46
|
*/
|
|
47
|
-
page: Page,
|
|
48
|
-
/**
|
|
47
|
+
page: Page, /**
|
|
49
48
|
* Name of the screenshot. Must be unique.
|
|
50
49
|
*/
|
|
51
|
-
name: string,
|
|
52
|
-
/**
|
|
50
|
+
name: string, /**
|
|
53
51
|
* Options for the screenshot.
|
|
54
52
|
*/
|
|
55
53
|
options?: ArgosScreenshotOptions): Promise<void>;
|
|
56
54
|
/**
|
|
57
55
|
* Get the CSP script hash.
|
|
58
56
|
*/
|
|
59
|
-
declare function getCSPScriptHash(): string
|
|
60
|
-
|
|
57
|
+
declare function getCSPScriptHash(): Promise<string>;
|
|
58
|
+
type PlaywrightLibrary = "@playwright/test" | "playwright" | "playwright-core";
|
|
59
|
+
type MetadataConfig = {
|
|
60
|
+
sdk: ScreenshotMetadata["sdk"];
|
|
61
|
+
playwrightLibraries: PlaywrightLibrary[];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Set the metadata config.
|
|
65
|
+
*/
|
|
66
|
+
declare function setMetadataConfig(metadata: MetadataConfig): Promise<void>;
|
|
67
|
+
export { ArgosScreenshotOptions, argosScreenshot, getCSPScriptHash, setMetadataConfig as DO_NOT_USE_setMetadataConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,44 @@
|
|
|
1
1
|
import { mkdir } from 'node:fs/promises';
|
|
2
2
|
import { relative, resolve, dirname } from 'node:path';
|
|
3
|
-
import { createHash } from 'node:crypto';
|
|
4
3
|
import { resolveViewport, getGlobalScript } from '@argos-ci/browser';
|
|
5
4
|
import { getGitRepositoryPath, readVersionFromPackage, getScreenshotName, validateThreshold, writeMetadata, getMetadataPath } from '@argos-ci/util';
|
|
6
5
|
import { createRequire } from 'node:module';
|
|
6
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
7
8
|
|
|
8
9
|
function getAttachmentName(name, type) {
|
|
9
10
|
return `argos/${type}___${name}`;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const require$1 = createRequire(import.meta.url);
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Try to resolve a package.
|
|
16
|
+
*/ function tryResolve(pkg) {
|
|
14
17
|
try {
|
|
15
18
|
return require$1.resolve(pkg);
|
|
16
19
|
} catch {
|
|
17
20
|
return null;
|
|
18
21
|
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Private metadata config storage.
|
|
25
|
+
* Used to inject the metadata from other SDKs like @argos-ci/storybook.
|
|
26
|
+
*/ const metadataConfigStorage = new AsyncLocalStorage();
|
|
27
|
+
/**
|
|
28
|
+
* Set the metadata config.
|
|
29
|
+
*/ async function setMetadataConfig(metadata) {
|
|
30
|
+
metadataConfigStorage.enterWith(metadata);
|
|
31
|
+
}
|
|
32
|
+
const DEFAULT_PLAYWRIGHT_LIBRARIES = [
|
|
33
|
+
"@playwright/test",
|
|
34
|
+
"playwright",
|
|
35
|
+
"playwright-core"
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* Get the name and version of the automation library.
|
|
39
|
+
*/ async function getAutomationLibraryMetadata() {
|
|
40
|
+
const metadataConfig = metadataConfigStorage.getStore();
|
|
41
|
+
const libraries = metadataConfig?.playwrightLibraries ?? DEFAULT_PLAYWRIGHT_LIBRARIES;
|
|
26
42
|
for (const name of libraries){
|
|
27
43
|
const pkgPath = tryResolve(`${name}/package.json`);
|
|
28
44
|
if (pkgPath) {
|
|
@@ -35,25 +51,42 @@ async function getAutomationLibrary() {
|
|
|
35
51
|
}
|
|
36
52
|
throw new Error(`Unable to find any of the following packages: ${libraries.join(", ")}`);
|
|
37
53
|
}
|
|
38
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Get the version of the Argos Playwright SDK.
|
|
56
|
+
*/ async function getArgosPlaywrightVersion() {
|
|
39
57
|
const pkgPath = require$1.resolve("@argos-ci/playwright/package.json");
|
|
40
58
|
return readVersionFromPackage(pkgPath);
|
|
41
59
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Get the name and version of the SDK.
|
|
62
|
+
*/ async function getSdkMetadata() {
|
|
63
|
+
// Get the SDK metadata from the async local storage.
|
|
64
|
+
const metadataConfig = metadataConfigStorage.getStore();
|
|
65
|
+
if (metadataConfig) {
|
|
66
|
+
return metadataConfig.sdk;
|
|
67
|
+
}
|
|
68
|
+
// Get the SDK metadata from the current SDK.
|
|
69
|
+
const argosPlaywrightVersion = await getArgosPlaywrightVersion();
|
|
70
|
+
return {
|
|
71
|
+
name: "@argos-ci/playwright",
|
|
72
|
+
version: argosPlaywrightVersion
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get the metadata of the automation library and the SDK.
|
|
77
|
+
*/ async function getLibraryMetadata() {
|
|
78
|
+
const [automationLibrary, sdk] = await Promise.all([
|
|
79
|
+
getAutomationLibraryMetadata(),
|
|
80
|
+
getSdkMetadata()
|
|
46
81
|
]);
|
|
47
|
-
|
|
82
|
+
return {
|
|
48
83
|
automationLibrary,
|
|
49
|
-
sdk
|
|
50
|
-
name: "@argos-ci/playwright",
|
|
51
|
-
version: argosPlaywrightVersion
|
|
52
|
-
}
|
|
84
|
+
sdk
|
|
53
85
|
};
|
|
54
|
-
return metadata;
|
|
55
86
|
}
|
|
56
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Get the metadata of the test.
|
|
89
|
+
*/ async function getTestMetadataFromTestInfo(testInfo) {
|
|
57
90
|
const repositoryPath = await getGitRepositoryPath();
|
|
58
91
|
const testMetadata = {
|
|
59
92
|
id: testInfo.testId,
|
|
@@ -88,7 +121,9 @@ const DEFAULT_SCREENSHOT_ROOT = "./screenshots";
|
|
|
88
121
|
});
|
|
89
122
|
}
|
|
90
123
|
}
|
|
91
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Get test info from the Playwright test.
|
|
126
|
+
*/ async function getTestInfo() {
|
|
92
127
|
try {
|
|
93
128
|
const { test } = await import('@playwright/test');
|
|
94
129
|
return test.info();
|
|
@@ -96,7 +131,9 @@ async function getTestInfo() {
|
|
|
96
131
|
return null;
|
|
97
132
|
}
|
|
98
133
|
}
|
|
99
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Get the viewport size.
|
|
136
|
+
*/ function getViewportSize(page) {
|
|
100
137
|
const viewportSize = page.viewportSize();
|
|
101
138
|
if (!viewportSize) {
|
|
102
139
|
throw new Error("Can't take screenshots without a viewport.");
|
|
@@ -286,11 +323,12 @@ function getViewportSize(page) {
|
|
|
286
323
|
}
|
|
287
324
|
await teardown();
|
|
288
325
|
}
|
|
326
|
+
|
|
289
327
|
/**
|
|
290
328
|
* Get the CSP script hash.
|
|
291
|
-
*/ function getCSPScriptHash() {
|
|
329
|
+
*/ async function getCSPScriptHash() {
|
|
292
330
|
const hash = createHash("sha256").update(getGlobalScript()).digest("base64");
|
|
293
331
|
return `'sha256-${hash}'`;
|
|
294
332
|
}
|
|
295
333
|
|
|
296
|
-
export { argosScreenshot, getCSPScriptHash };
|
|
334
|
+
export { setMetadataConfig as DO_NOT_USE_setMetadataConfig, argosScreenshot, getCSPScriptHash };
|
package/dist/reporter.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { tmpdir } from 'node:os';
|
|
|
6
6
|
import { relative, dirname, join } from 'node:path';
|
|
7
7
|
import { getGitRepositoryPath, readVersionFromPackage } from '@argos-ci/util';
|
|
8
8
|
import { createRequire } from 'node:module';
|
|
9
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
9
10
|
import createDebug from 'debug';
|
|
10
11
|
|
|
11
12
|
function getOriginalAttachmentName(name) {
|
|
@@ -34,19 +35,29 @@ function checkIsAutomaticScreenshot(attachment) {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
const require = createRequire(import.meta.url);
|
|
37
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Try to resolve a package.
|
|
40
|
+
*/ function tryResolve(pkg) {
|
|
38
41
|
try {
|
|
39
42
|
return require.resolve(pkg);
|
|
40
43
|
} catch {
|
|
41
44
|
return null;
|
|
42
45
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Private metadata config storage.
|
|
49
|
+
* Used to inject the metadata from other SDKs like @argos-ci/storybook.
|
|
50
|
+
*/ const metadataConfigStorage = new AsyncLocalStorage();
|
|
51
|
+
const DEFAULT_PLAYWRIGHT_LIBRARIES = [
|
|
52
|
+
"@playwright/test",
|
|
53
|
+
"playwright",
|
|
54
|
+
"playwright-core"
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* Get the name and version of the automation library.
|
|
58
|
+
*/ async function getAutomationLibraryMetadata() {
|
|
59
|
+
const metadataConfig = metadataConfigStorage.getStore();
|
|
60
|
+
const libraries = metadataConfig?.playwrightLibraries ?? DEFAULT_PLAYWRIGHT_LIBRARIES;
|
|
50
61
|
for (const name of libraries){
|
|
51
62
|
const pkgPath = tryResolve(`${name}/package.json`);
|
|
52
63
|
if (pkgPath) {
|
|
@@ -59,23 +70,38 @@ async function getAutomationLibrary() {
|
|
|
59
70
|
}
|
|
60
71
|
throw new Error(`Unable to find any of the following packages: ${libraries.join(", ")}`);
|
|
61
72
|
}
|
|
62
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Get the version of the Argos Playwright SDK.
|
|
75
|
+
*/ async function getArgosPlaywrightVersion() {
|
|
63
76
|
const pkgPath = require.resolve("@argos-ci/playwright/package.json");
|
|
64
77
|
return readVersionFromPackage(pkgPath);
|
|
65
78
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Get the name and version of the SDK.
|
|
81
|
+
*/ async function getSdkMetadata() {
|
|
82
|
+
// Get the SDK metadata from the async local storage.
|
|
83
|
+
const metadataConfig = metadataConfigStorage.getStore();
|
|
84
|
+
if (metadataConfig) {
|
|
85
|
+
return metadataConfig.sdk;
|
|
86
|
+
}
|
|
87
|
+
// Get the SDK metadata from the current SDK.
|
|
88
|
+
const argosPlaywrightVersion = await getArgosPlaywrightVersion();
|
|
89
|
+
return {
|
|
90
|
+
name: "@argos-ci/playwright",
|
|
91
|
+
version: argosPlaywrightVersion
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the metadata of the automation library and the SDK.
|
|
96
|
+
*/ async function getLibraryMetadata() {
|
|
97
|
+
const [automationLibrary, sdk] = await Promise.all([
|
|
98
|
+
getAutomationLibraryMetadata(),
|
|
99
|
+
getSdkMetadata()
|
|
70
100
|
]);
|
|
71
|
-
|
|
101
|
+
return {
|
|
72
102
|
automationLibrary,
|
|
73
|
-
sdk
|
|
74
|
-
name: "@argos-ci/playwright",
|
|
75
|
-
version: argosPlaywrightVersion
|
|
76
|
-
}
|
|
103
|
+
sdk
|
|
77
104
|
};
|
|
78
|
-
return metadata;
|
|
79
105
|
}
|
|
80
106
|
async function getTestMetadataFromTestCase(testCase, testResult) {
|
|
81
107
|
const repositoryPath = await getGitRepositoryPath();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/playwright",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "3.
|
|
3
|
+
"description": "Playwright SDK for visual testing with Argos.",
|
|
4
|
+
"version": "3.8.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -9,11 +9,16 @@
|
|
|
9
9
|
"url": "https://github.com/argos-ci/argos-javascript.git",
|
|
10
10
|
"directory": "packages/playwright"
|
|
11
11
|
},
|
|
12
|
+
"homepage": "https://argos-ci.com/docs/playwright",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/argos-ci/argos-javascript/issues"
|
|
15
|
+
},
|
|
12
16
|
"keywords": [
|
|
13
17
|
"playwright",
|
|
18
|
+
"playwright-reporter",
|
|
19
|
+
"reporter",
|
|
20
|
+
"playwright-plugin",
|
|
14
21
|
"argos",
|
|
15
|
-
"automation",
|
|
16
|
-
"test automation",
|
|
17
22
|
"testing",
|
|
18
23
|
"visual testing",
|
|
19
24
|
"regression",
|
|
@@ -39,19 +44,19 @@
|
|
|
39
44
|
"./package.json": "./package.json"
|
|
40
45
|
},
|
|
41
46
|
"engines": {
|
|
42
|
-
"node": ">=18.
|
|
47
|
+
"node": ">=18.16.0"
|
|
43
48
|
},
|
|
44
49
|
"dependencies": {
|
|
45
|
-
"@argos-ci/browser": "2.1.
|
|
46
|
-
"@argos-ci/core": "2.9.
|
|
47
|
-
"@argos-ci/util": "2.1.
|
|
50
|
+
"@argos-ci/browser": "2.1.6",
|
|
51
|
+
"@argos-ci/core": "2.9.2",
|
|
52
|
+
"@argos-ci/util": "2.1.2",
|
|
48
53
|
"chalk": "^5.3.0",
|
|
49
54
|
"debug": "^4.3.6"
|
|
50
55
|
},
|
|
51
56
|
"devDependencies": {
|
|
52
|
-
"@argos-ci/cli": "2.4.
|
|
57
|
+
"@argos-ci/cli": "2.4.7",
|
|
53
58
|
"@argos-ci/playwright": "workspace:.",
|
|
54
|
-
"@playwright/test": "^1.
|
|
59
|
+
"@playwright/test": "^1.48.1",
|
|
55
60
|
"@types/debug": "^4.1.12",
|
|
56
61
|
"@types/node": "^18.19.44"
|
|
57
62
|
},
|
|
@@ -61,5 +66,5 @@
|
|
|
61
66
|
"test": "pnpm exec -- playwright test",
|
|
62
67
|
"e2e": "UPLOAD_TO_ARGOS=true pnpm run test"
|
|
63
68
|
},
|
|
64
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "d0fa8cd790ffd2343d1cd32706bcb757c4f3b26e"
|
|
65
70
|
}
|