@argos-ci/playwright 1.8.0 → 1.9.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 +6 -1
- package/dist/index.mjs +30 -17
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ type ArgosScreenshotOptions = {
|
|
|
15
15
|
* Custom CSS evaluated during the screenshot process.
|
|
16
16
|
*/
|
|
17
17
|
argosCSS?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Disable hover effects by moving the mouse to the top-left corner of the page.
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
disableHover?: boolean;
|
|
18
23
|
} & LocatorOptions & ScreenshotOptions<LocatorScreenshotOptions> & ScreenshotOptions<PageScreenshotOptions>;
|
|
19
|
-
declare function argosScreenshot(page: Page, name: string,
|
|
24
|
+
declare function argosScreenshot(page: Page, name: string, options?: ArgosScreenshotOptions): Promise<void>;
|
|
20
25
|
export { ArgosScreenshotOptions, argosScreenshot };
|
package/dist/index.mjs
CHANGED
|
@@ -100,7 +100,33 @@ function getViewportSize(page) {
|
|
|
100
100
|
}
|
|
101
101
|
return viewportSize;
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Setup Argos for the screenshot process.
|
|
105
|
+
* @returns A function to teardown Argos.
|
|
106
|
+
*/ async function setup(page, options) {
|
|
107
|
+
const { disableHover = true, fullPage, argosCSS } = options;
|
|
108
|
+
await page.evaluate(({ fullPage, argosCSS })=>window.__ARGOS__.setup({
|
|
109
|
+
fullPage,
|
|
110
|
+
argosCSS
|
|
111
|
+
}), {
|
|
112
|
+
fullPage,
|
|
113
|
+
argosCSS
|
|
114
|
+
});
|
|
115
|
+
if (disableHover) {
|
|
116
|
+
await page.mouse.move(0, 0);
|
|
117
|
+
}
|
|
118
|
+
return async ()=>{
|
|
119
|
+
await page.evaluate(({ fullPage, argosCSS })=>window.__ARGOS__.teardown({
|
|
120
|
+
fullPage,
|
|
121
|
+
argosCSS
|
|
122
|
+
}), {
|
|
123
|
+
fullPage,
|
|
124
|
+
argosCSS
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async function argosScreenshot(page, name, options = {}) {
|
|
129
|
+
const { element, has, hasText, viewports, argosCSS, ...playwrightOptions } = options;
|
|
104
130
|
if (!page) {
|
|
105
131
|
throw new Error("A Playwright `page` object is required.");
|
|
106
132
|
}
|
|
@@ -123,13 +149,7 @@ async function argosScreenshot(page, name, { element, has, hasText, viewports, a
|
|
|
123
149
|
]);
|
|
124
150
|
const originalViewportSize = getViewportSize(page);
|
|
125
151
|
const fullPage = options.fullPage !== undefined ? options.fullPage : handle === page;
|
|
126
|
-
await page
|
|
127
|
-
fullPage,
|
|
128
|
-
argosCSS
|
|
129
|
-
}), {
|
|
130
|
-
fullPage,
|
|
131
|
-
argosCSS
|
|
132
|
-
});
|
|
152
|
+
const teardown = await setup(page, options);
|
|
133
153
|
async function collectMetadata(testInfo) {
|
|
134
154
|
const [colorScheme, mediaType, libMetadata, testMetadata] = await Promise.all([
|
|
135
155
|
page.evaluate(()=>window.__ARGOS__.getColorScheme()),
|
|
@@ -179,7 +199,7 @@ async function argosScreenshot(page, name, { element, has, hasText, viewports, a
|
|
|
179
199
|
page.locator('[data-visual-test="blackout"]')
|
|
180
200
|
],
|
|
181
201
|
animations: "disabled",
|
|
182
|
-
...
|
|
202
|
+
...playwrightOptions
|
|
183
203
|
}),
|
|
184
204
|
screenshotPath ? writeMetadata(screenshotPath, metadata) : null
|
|
185
205
|
]);
|
|
@@ -211,14 +231,7 @@ async function argosScreenshot(page, name, { element, has, hasText, viewports, a
|
|
|
211
231
|
} else {
|
|
212
232
|
await stabilizeAndScreenshot(name);
|
|
213
233
|
}
|
|
214
|
-
|
|
215
|
-
await page.evaluate(({ fullPage, argosCSS })=>window.__ARGOS__.teardown({
|
|
216
|
-
fullPage,
|
|
217
|
-
argosCSS
|
|
218
|
-
}), {
|
|
219
|
-
fullPage,
|
|
220
|
-
argosCSS
|
|
221
|
-
});
|
|
234
|
+
await teardown();
|
|
222
235
|
}
|
|
223
236
|
|
|
224
237
|
export { argosScreenshot };
|
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": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"node": ">=16.0.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@argos-ci/browser": "1.4.
|
|
46
|
-
"@argos-ci/core": "1.5.
|
|
45
|
+
"@argos-ci/browser": "1.4.1",
|
|
46
|
+
"@argos-ci/core": "1.5.2",
|
|
47
47
|
"@argos-ci/util": "1.2.0",
|
|
48
48
|
"chalk": "^5.3.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@argos-ci/cli": "1.0.
|
|
51
|
+
"@argos-ci/cli": "1.0.9",
|
|
52
52
|
"@argos-ci/playwright": "workspace:.",
|
|
53
53
|
"@playwright/test": "^1.38.1",
|
|
54
54
|
"@types/node": "^16.0.0"
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"test": "pnpm exec playwright test",
|
|
60
60
|
"e2e": "UPLOAD_TO_ARGOS=true pnpm run test"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "47e813466b9224cb428eb44ee4d4d450f737763e"
|
|
63
63
|
}
|