@argos-ci/webdriverio 0.1.1 → 0.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.d.ts +9 -2
- package/dist/index.mjs +13 -6
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -20,8 +20,15 @@ type ArgosScreenshotOptions = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Take a screenshot of the current page, optionally masking certain areas.
|
|
22
22
|
* @param browser A WebdriverIO `browser` object.
|
|
23
|
-
* @param
|
|
24
|
-
* @param options Options
|
|
23
|
+
* @param name The name of the screenshot or the full path to the screenshot.
|
|
24
|
+
* @param options Options to customize the screenshot.
|
|
25
|
+
* @param options.mask
|
|
26
|
+
* Specify ares that should be masked when the screenshot is taken.
|
|
27
|
+
* Masked elements will be overlaid with a pink box #FF00FF (customized by maskColor)
|
|
28
|
+
* that completely covers its bounding box.
|
|
29
|
+
* @param options.maskColor
|
|
30
|
+
* Specify the color of the overlay box for masked elements, in CSS color format.
|
|
31
|
+
* Default color is pink #FF00FF.
|
|
25
32
|
*/
|
|
26
33
|
declare function argosScreenshot(browser: WebdriverIO.Browser, name: string, { mask, maskColor }?: ArgosScreenshotOptions): Promise<Buffer>;
|
|
27
34
|
export { ArgosScreenshotOptions, argosScreenshot };
|
package/dist/index.mjs
CHANGED
|
@@ -57,7 +57,7 @@ async function getImageDimensions(buffer) {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
async function
|
|
60
|
+
async function getScreenshotPath(name) {
|
|
61
61
|
if (name.endsWith(".png")) return name;
|
|
62
62
|
const screenshotFolder = resolve(process.cwd(), "screenshots/argos");
|
|
63
63
|
await mkdir(screenshotFolder, {
|
|
@@ -68,8 +68,15 @@ async function getFilePath(name) {
|
|
|
68
68
|
/**
|
|
69
69
|
* Take a screenshot of the current page, optionally masking certain areas.
|
|
70
70
|
* @param browser A WebdriverIO `browser` object.
|
|
71
|
-
* @param
|
|
72
|
-
* @param options Options
|
|
71
|
+
* @param name The name of the screenshot or the full path to the screenshot.
|
|
72
|
+
* @param options Options to customize the screenshot.
|
|
73
|
+
* @param options.mask
|
|
74
|
+
* Specify ares that should be masked when the screenshot is taken.
|
|
75
|
+
* Masked elements will be overlaid with a pink box #FF00FF (customized by maskColor)
|
|
76
|
+
* that completely covers its bounding box.
|
|
77
|
+
* @param options.maskColor
|
|
78
|
+
* Specify the color of the overlay box for masked elements, in CSS color format.
|
|
79
|
+
* Default color is pink #FF00FF.
|
|
73
80
|
*/ async function argosScreenshot(browser, name, { mask, maskColor = "#FF00FF" } = {}) {
|
|
74
81
|
if (!browser) {
|
|
75
82
|
throw new Error("A WebdriverIO `browser` object is required.");
|
|
@@ -77,15 +84,15 @@ async function getFilePath(name) {
|
|
|
77
84
|
if (!name) {
|
|
78
85
|
throw new Error("The `name` argument is required.");
|
|
79
86
|
}
|
|
80
|
-
const
|
|
81
|
-
const imageBuffer = await browser.saveScreenshot(
|
|
87
|
+
const screenshotPath = await getScreenshotPath(name);
|
|
88
|
+
const imageBuffer = await browser.saveScreenshot(screenshotPath);
|
|
82
89
|
if (!mask) {
|
|
83
90
|
return imageBuffer;
|
|
84
91
|
}
|
|
85
92
|
const dimensions = await getImageDimensions(imageBuffer);
|
|
86
93
|
const maskBuffer = await createMask(dimensions, mask, maskColor);
|
|
87
94
|
const maskedBuffer = await applyMask(imageBuffer, maskBuffer);
|
|
88
|
-
await sharp(maskedBuffer).toFile(
|
|
95
|
+
await sharp(maskedBuffer).toFile(screenshotPath);
|
|
89
96
|
return maskedBuffer;
|
|
90
97
|
}
|
|
91
98
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/webdriverio",
|
|
3
3
|
"description": "Visual testing solution to avoid visual regression. Webdriver SDK and utilities for Argos visual testing.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"sharp": "^0.32.5"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@argos-ci/cli": "1.0.
|
|
46
|
+
"@argos-ci/cli": "1.0.6",
|
|
47
47
|
"@types/mocha": "^10.0.6",
|
|
48
48
|
"@wdio/cli": "^8.27.1",
|
|
49
49
|
"@wdio/globals": "^8.27.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"argos-upload": "pnpm exec argos upload screenshots --build-name \"argos-webdriverio-e2e-node-$NODE_VERSION-$OS\"",
|
|
64
64
|
"e2e": "pnpm run test && pnpm run argos-upload"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "0d2a6514fa5765f4ced8cdff38a6c530f44d2e01"
|
|
67
67
|
}
|