@argos-ci/playwright 0.0.5 → 0.0.7
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.mjs +19 -8
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ const GLOBAL_STYLES = `
|
|
|
17
17
|
font-family: monospace !important;
|
|
18
18
|
opacity: 0 !important;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
[data-visual-test="removed"] {
|
|
22
22
|
display: none !important;
|
|
23
23
|
}
|
|
@@ -32,6 +32,13 @@ function waitForImagesLoading() {
|
|
|
32
32
|
allImages.forEach((img)=>img.loading = "eager");
|
|
33
33
|
return allImages.every((img)=>img.complete);
|
|
34
34
|
}
|
|
35
|
+
// Disable spellcheck to avoid red underlines
|
|
36
|
+
function disableSpellCheck() {
|
|
37
|
+
const query = "[contenteditable]:not([contenteditable=false]):not([spellcheck=false]), input:not([spellcheck=false]), textarea:not([spellcheck=false])";
|
|
38
|
+
const inputs = document.querySelectorAll(query);
|
|
39
|
+
inputs.forEach((input)=>input.setAttribute("spellcheck", "false"));
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
35
42
|
async function argosScreenshot(page, name, { element , has , hasText , ...options } = {}) {
|
|
36
43
|
if (!page) throw new Error("A Playwright `page` object is required.");
|
|
37
44
|
if (!name) throw new Error("The `name` argument is required.");
|
|
@@ -42,15 +49,19 @@ async function argosScreenshot(page, name, { element , has , hasText , ...option
|
|
|
42
49
|
mkdir(screenshotFolder, {
|
|
43
50
|
recursive: true
|
|
44
51
|
});
|
|
52
|
+
// Inject global styles
|
|
53
|
+
await page.addStyleTag({
|
|
54
|
+
content: GLOBAL_STYLES
|
|
55
|
+
});
|
|
56
|
+
// Wait for all busy elements to be loaded
|
|
57
|
+
await page.waitForSelector('[aria-busy="true"]', {
|
|
58
|
+
state: "hidden"
|
|
59
|
+
});
|
|
60
|
+
// Code injection to improve the screenshot stability
|
|
45
61
|
await Promise.all([
|
|
46
|
-
page.addStyleTag({
|
|
47
|
-
content: GLOBAL_STYLES
|
|
48
|
-
}),
|
|
49
|
-
page.waitForSelector('[aria-busy="true"]', {
|
|
50
|
-
state: "hidden"
|
|
51
|
-
}),
|
|
52
62
|
page.waitForFunction(waitForImagesLoading),
|
|
53
|
-
page.waitForFunction(waitForFontLoading)
|
|
63
|
+
page.waitForFunction(waitForFontLoading),
|
|
64
|
+
page.waitForFunction(disableSpellCheck)
|
|
54
65
|
]);
|
|
55
66
|
await handle.screenshot({
|
|
56
67
|
path: resolve(screenshotFolder, `${name}.png`),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/playwright",
|
|
3
3
|
"description": "Visual testing solution to avoid visual regression. Playwright commands and utilities for Argos visual testing.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:argos-ci/argos-playwright",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"format": "prettier --write . --ignore-path .gitignore",
|
|
40
40
|
"check-format": "prettier --check .",
|
|
41
41
|
"lint": "eslint --ignore-path .gitignore .",
|
|
42
|
+
"prepublishOnly": "npm run build",
|
|
42
43
|
"release": "standard-version && conventional-github-releaser --preset angular"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|