@argos-ci/puppeteer 0.0.2 → 0.0.4-alpha.182
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/LICENSE +1 -1
- package/README.md +3 -3
- package/package.json +30 -25
- package/index.cjs +0 -6
- package/index.d.ts +0 -24
- package/index.js +0 -99
package/LICENSE
CHANGED
|
@@ -4,4 +4,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
4
4
|
|
|
5
5
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
6
|
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ _Argos is a visual testing solution that fits in your workflow to avoid visual r
|
|
|
12
12
|
[](https://www.npmjs.com/package/@argos-ci/puppeteer)
|
|
13
13
|
[](https://www.npmjs.com/package/@argos-ci/puppeteer)
|
|
14
14
|
|
|
15
|
-
Visit [
|
|
15
|
+
Visit [argos-ci.com/docs/puppeteer](https://argos-ci.com/docs/puppeteer) for guides, API and more.
|
|
16
16
|
|
|
17
17
|
## Links
|
|
18
18
|
|
|
19
|
-
- [Official SDK Docs](https://
|
|
20
|
-
- [Discord](https://
|
|
19
|
+
- [Official SDK Docs](https://argos-ci.com/docs/)
|
|
20
|
+
- [Discord](https://argos-ci.com/discord)
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
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": "0.0.
|
|
4
|
+
"version": "0.0.4-alpha.182+8a2e9db",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"repository":
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/argos-ci/argos-javascript.git",
|
|
10
|
+
"directory": "packages/puppeteer"
|
|
11
|
+
},
|
|
8
12
|
"keywords": [
|
|
9
13
|
"puppeteer",
|
|
10
14
|
"argos",
|
|
@@ -18,44 +22,45 @@
|
|
|
18
22
|
"publishConfig": {
|
|
19
23
|
"access": "public"
|
|
20
24
|
},
|
|
21
|
-
"engines": {
|
|
22
|
-
"node": ">=16"
|
|
23
|
-
},
|
|
24
25
|
"type": "module",
|
|
25
26
|
"exports": {
|
|
26
27
|
".": {
|
|
27
|
-
"import": "./index.
|
|
28
|
-
"require": "./index.cjs",
|
|
29
|
-
"types": "./index.d.ts",
|
|
30
|
-
"default": "./index.
|
|
28
|
+
"import": "./dist/index.mjs",
|
|
29
|
+
"require": "./dist/index.cjs",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.mjs"
|
|
31
32
|
},
|
|
32
33
|
"./package.json": "./package.json"
|
|
33
34
|
},
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"test": "npm run jest --runInBand",
|
|
37
|
-
"format": "prettier --write .",
|
|
38
|
-
"check-format": "prettier --check .",
|
|
39
|
-
"lint": "eslint --ignore-path .gitignore .",
|
|
40
|
-
"release": "standard-version && conventional-github-releaser --preset angular"
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=16.0.0"
|
|
41
37
|
},
|
|
42
38
|
"peerDependencies": {
|
|
43
39
|
"puppeteer": ">=1"
|
|
44
40
|
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@argos-ci/browser": "0.0.1-alpha.182+8a2e9db",
|
|
43
|
+
"@argos-ci/util": "0.0.1-alpha.182+8a2e9db"
|
|
44
|
+
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@argos-ci/cli": "
|
|
46
|
+
"@argos-ci/cli": "0.6.1-alpha.4+8a2e9db",
|
|
47
47
|
"@types/jest": "^28.1.8",
|
|
48
|
-
"
|
|
48
|
+
"@types/node": "^16.0.0",
|
|
49
49
|
"eslint": "^8.23.0",
|
|
50
50
|
"eslint-plugin-html": "^7.1.0",
|
|
51
|
+
"expect-puppeteer": "^9.0.1",
|
|
51
52
|
"jest": "^29.0.1",
|
|
52
53
|
"jest-light-runner": "^0.4.0",
|
|
53
|
-
"jest-puppeteer": "^
|
|
54
|
-
"
|
|
55
|
-
"puppeteer": "^17.0.0",
|
|
56
|
-
"standard-version": "^9.5.0"
|
|
54
|
+
"jest-puppeteer": "^9.0.1",
|
|
55
|
+
"puppeteer": "^21.3.6"
|
|
57
56
|
},
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
57
|
+
"scripts": {
|
|
58
|
+
"prebuild": "rm -rf dist",
|
|
59
|
+
"build": "rollup -c",
|
|
60
|
+
"jest": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
61
|
+
"test": "pnpm run jest --runInBand",
|
|
62
|
+
"argos-upload": "pnpm exec argos upload screenshots --build-name \"argos-puppeteer-e2e-node-$NODE_VERSION-$OS\"",
|
|
63
|
+
"e2e": "pnpm run test && pnpm run argos-upload"
|
|
64
|
+
},
|
|
65
|
+
"gitHead": "8a2e9db6427071708c3d701a3230f228b1216893"
|
|
61
66
|
}
|
package/index.cjs
DELETED
package/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Page, ScreenshotOptions, ElementHandle } from "puppeteer";
|
|
2
|
-
|
|
3
|
-
export interface ArgosScreenshotOptions
|
|
4
|
-
extends Omit<
|
|
5
|
-
ScreenshotOptions,
|
|
6
|
-
"encoding" | "type" | "omitBackground" | "path"
|
|
7
|
-
> {
|
|
8
|
-
/**
|
|
9
|
-
* ElementHandle or string selector of the element to take a screenshot of.
|
|
10
|
-
*/
|
|
11
|
-
element?: string | ElementHandle;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Stabilize the UI and takes a screenshot of the application under test.
|
|
16
|
-
* @example
|
|
17
|
-
* await argosScreenshot(page, "my-screenshot")
|
|
18
|
-
* await argosScreenshot(page, "my-screenshot", { fullPage: true })
|
|
19
|
-
*/
|
|
20
|
-
export function argosScreenshot(
|
|
21
|
-
page: Page,
|
|
22
|
-
name: string,
|
|
23
|
-
options?: ArgosScreenshotOptions
|
|
24
|
-
): Promise<void>;
|
package/index.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
2
|
-
import mkdirp from "mkdirp";
|
|
3
|
-
|
|
4
|
-
const GLOBAL_STYLES = `
|
|
5
|
-
/* Hide carets */
|
|
6
|
-
* { caret-color: transparent !important; }
|
|
7
|
-
|
|
8
|
-
/* Hide scrollbars */
|
|
9
|
-
::-webkit-scrollbar {
|
|
10
|
-
display: none !important;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* Generic hide */
|
|
14
|
-
[data-visual-test="transparent"] {
|
|
15
|
-
color: transparent !important;
|
|
16
|
-
font-family: monospace !important;
|
|
17
|
-
opacity: 0 !important;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
[data-visual-test="removed"] {
|
|
21
|
-
display: none !important;
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Check if there is `[aria-busy="true"]` element on the page.
|
|
27
|
-
*/
|
|
28
|
-
async function ensureNoBusy() {
|
|
29
|
-
const checkIsVisible = (element) =>
|
|
30
|
-
Boolean(
|
|
31
|
-
element.offsetWidth ||
|
|
32
|
-
element.offsetHeight ||
|
|
33
|
-
element.getClientRects().length
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return [...document.querySelectorAll('[aria-busy="true"]')].every(
|
|
37
|
-
(element) => !checkIsVisible(element)
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Wait for all fonts to be loaded.
|
|
43
|
-
*/
|
|
44
|
-
function waitForFonts() {
|
|
45
|
-
return document.fonts.status === "loaded";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Wait for all images to be loaded.
|
|
50
|
-
*/
|
|
51
|
-
async function waitForImages() {
|
|
52
|
-
return Promise.all(
|
|
53
|
-
Array.from(document.images)
|
|
54
|
-
.filter((img) => !img.complete)
|
|
55
|
-
.map(
|
|
56
|
-
(img) =>
|
|
57
|
-
new Promise((resolve) => {
|
|
58
|
-
img.onload = img.onerror = resolve;
|
|
59
|
-
})
|
|
60
|
-
)
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export async function argosScreenshot(
|
|
65
|
-
page,
|
|
66
|
-
name,
|
|
67
|
-
{ element = page, ...options } = {}
|
|
68
|
-
) {
|
|
69
|
-
if (!page) throw new Error("A Puppeteer `page` object is required.");
|
|
70
|
-
if (!name) throw new Error("The `name` argument is required.");
|
|
71
|
-
|
|
72
|
-
if (typeof element === "string") {
|
|
73
|
-
await page.waitForSelector(element);
|
|
74
|
-
element = await page.$(element);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const directory = resolve(process.cwd(), "screenshots/argos");
|
|
78
|
-
|
|
79
|
-
const [resolvedElement] = await Promise.all([
|
|
80
|
-
(async () => {
|
|
81
|
-
if (typeof element === "string") {
|
|
82
|
-
await page.waitForSelector(element);
|
|
83
|
-
return page.$(element);
|
|
84
|
-
}
|
|
85
|
-
return element;
|
|
86
|
-
})(),
|
|
87
|
-
mkdirp(directory),
|
|
88
|
-
page.addStyleTag({ content: GLOBAL_STYLES }),
|
|
89
|
-
page.waitForFunction(ensureNoBusy),
|
|
90
|
-
page.waitForFunction(waitForFonts),
|
|
91
|
-
page.waitForFunction(waitForImages),
|
|
92
|
-
]);
|
|
93
|
-
|
|
94
|
-
await resolvedElement.screenshot({
|
|
95
|
-
path: resolve(directory, `${name}.png`),
|
|
96
|
-
type: "png",
|
|
97
|
-
...options,
|
|
98
|
-
});
|
|
99
|
-
}
|