@argos-ci/puppeteer 2.1.4 → 2.2.1
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 +27 -7
- package/dist/index.mjs +18 -8
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ElementHandle, Page, ScreenshotOptions } from "puppeteer";
|
|
2
2
|
import { ViewportOption } from "@argos-ci/browser";
|
|
3
|
+
/**
|
|
4
|
+
* Accepts all Puppeteer screenshot options and adds Argos-specific options.
|
|
5
|
+
*/
|
|
3
6
|
type ArgosScreenshotOptions = Omit<ScreenshotOptions, "encoding" | "type" | "omitBackground" | "path"> & {
|
|
4
7
|
/**
|
|
5
8
|
* ElementHandle or string selector of the element to take a screenshot of.
|
|
@@ -18,14 +21,31 @@ type ArgosScreenshotOptions = Omit<ScreenshotOptions, "encoding" | "type" | "omi
|
|
|
18
21
|
* @default true
|
|
19
22
|
*/
|
|
20
23
|
disableHover?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Sensitivity threshold between 0 and 1.
|
|
26
|
+
* The higher the threshold, the less sensitive the diff will be.
|
|
27
|
+
* @default 0.5
|
|
28
|
+
*/
|
|
29
|
+
threshold?: number;
|
|
21
30
|
};
|
|
22
31
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
28
|
-
|
|
32
|
+
* Stabilize the UI and takes a screenshot of the application under test.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* argosScreenshot(page, "my-screenshot")
|
|
36
|
+
* @see https://argos-ci.com/docs/puppeteer#api-overview
|
|
37
|
+
*/
|
|
38
|
+
declare function argosScreenshot(
|
|
39
|
+
/**
|
|
40
|
+
* Puppeteer `page` object.
|
|
41
|
+
*/
|
|
42
|
+
page: Page,
|
|
43
|
+
/**
|
|
44
|
+
* Name of the screenshot. Must be unique.
|
|
45
|
+
*/
|
|
46
|
+
name: string,
|
|
47
|
+
/**
|
|
48
|
+
* Options for the screenshot.
|
|
29
49
|
*/
|
|
30
|
-
|
|
50
|
+
options?: ArgosScreenshotOptions): Promise<void>;
|
|
31
51
|
export { ArgosScreenshotOptions, argosScreenshot };
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { resolve } from 'node:path';
|
|
|
2
2
|
import { mkdir } from 'node:fs/promises';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { resolveViewport, getGlobalScript } from '@argos-ci/browser';
|
|
5
|
-
import { getScreenshotName, writeMetadata, readVersionFromPackage } from '@argos-ci/util';
|
|
5
|
+
import { getScreenshotName, writeMetadata, validateThreshold, readVersionFromPackage } from '@argos-ci/util';
|
|
6
6
|
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
8
|
/**
|
|
@@ -75,13 +75,18 @@ function checkIsFullPage(options) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @
|
|
81
|
-
*
|
|
82
|
-
* @
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
* Stabilize the UI and takes a screenshot of the application under test.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* argosScreenshot(page, "my-screenshot")
|
|
82
|
+
* @see https://argos-ci.com/docs/puppeteer#api-overview
|
|
83
|
+
*/ async function argosScreenshot(/**
|
|
84
|
+
* Puppeteer `page` object.
|
|
85
|
+
*/ page, /**
|
|
86
|
+
* Name of the screenshot. Must be unique.
|
|
87
|
+
*/ name, /**
|
|
88
|
+
* Options for the screenshot.
|
|
89
|
+
*/ options = {}) {
|
|
85
90
|
const { element, viewports, argosCSS, ...puppeteerOptions } = options;
|
|
86
91
|
if (!page) {
|
|
87
92
|
throw new Error("A Puppeteer `page` object is required.");
|
|
@@ -127,6 +132,11 @@ function checkIsFullPage(options) {
|
|
|
127
132
|
version: argosPuppeteerVersion
|
|
128
133
|
}
|
|
129
134
|
};
|
|
135
|
+
metadata.transient = {};
|
|
136
|
+
if (options?.threshold !== undefined) {
|
|
137
|
+
validateThreshold(options.threshold);
|
|
138
|
+
metadata.transient.threshold = options.threshold;
|
|
139
|
+
}
|
|
130
140
|
return metadata;
|
|
131
141
|
}
|
|
132
142
|
async function stabilizeAndScreenshot(name) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/puppeteer",
|
|
3
3
|
"description": "Visual testing solution to avoid visual regression. Puppeteer commands and utilities for Argos visual testing.",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@argos-ci/browser": "2.1.2",
|
|
44
|
-
"@argos-ci/util": "2.
|
|
44
|
+
"@argos-ci/util": "2.1.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@argos-ci/cli": "2.
|
|
47
|
+
"@argos-ci/cli": "2.3.1",
|
|
48
48
|
"@types/jest": "^29.5.12",
|
|
49
49
|
"@types/node": "^18.0.0",
|
|
50
50
|
"eslint": "^8.57.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"argos-upload": "pnpm exec argos upload screenshots --build-name \"argos-puppeteer-e2e-node-$NODE_VERSION-$OS\"",
|
|
64
64
|
"e2e": "pnpm run test && pnpm run argos-upload"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "8fbd0bb85ba9df1e8ca39d46acfe9903264d0b51"
|
|
67
67
|
}
|