@testmuai/playwright-bindings 0.1.6 → 0.1.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.
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import type { Page } from 'playwright';
|
|
1
|
+
import type { Page, PageScreenshotOptions } from 'playwright';
|
|
2
2
|
/**
|
|
3
3
|
* Internal helper: wait briefly then take a page screenshot.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Single source of truth for binding screenshot defaults. Used by every
|
|
6
|
+
* binding code path that screenshots the page (vision, wait, assertion).
|
|
7
|
+
* Not exported on the testmu namespace — internal use only.
|
|
8
|
+
*
|
|
9
|
+
* Defaults:
|
|
10
|
+
* - 300ms settle gives in-flight animations / lazy reflows a chance to land
|
|
11
|
+
* - timeout=60000ms (over Playwright's 30s default — large/animated DOMs
|
|
12
|
+
* occasionally exceed it on a settling screenshot)
|
|
13
|
+
* - type='jpeg', quality=80 (smaller payloads for vision-API uploads)
|
|
14
|
+
* - scale='css' (CSS pixels, not device pixels — consistent dimensions
|
|
15
|
+
* across HiDPI and SD runners)
|
|
9
16
|
*/
|
|
10
|
-
export declare function takeScreenshot(page: Page): Promise<Buffer>;
|
|
17
|
+
export declare function takeScreenshot(page: Page, options?: PageScreenshotOptions): Promise<Buffer>;
|
|
11
18
|
//# sourceMappingURL=screenshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/helpers/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/helpers/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,EACV,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal helper: wait briefly then take a page screenshot.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Single source of truth for binding screenshot defaults. Used by every
|
|
5
|
+
* binding code path that screenshots the page (vision, wait, assertion).
|
|
6
|
+
* Not exported on the testmu namespace — internal use only.
|
|
7
|
+
*
|
|
8
|
+
* Defaults:
|
|
9
|
+
* - 300ms settle gives in-flight animations / lazy reflows a chance to land
|
|
10
|
+
* - timeout=60000ms (over Playwright's 30s default — large/animated DOMs
|
|
11
|
+
* occasionally exceed it on a settling screenshot)
|
|
12
|
+
* - type='jpeg', quality=80 (smaller payloads for vision-API uploads)
|
|
13
|
+
* - scale='css' (CSS pixels, not device pixels — consistent dimensions
|
|
14
|
+
* across HiDPI and SD runners)
|
|
8
15
|
*/
|
|
9
|
-
export async function takeScreenshot(page) {
|
|
16
|
+
export async function takeScreenshot(page, options = {}) {
|
|
10
17
|
await page.waitForTimeout(300);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
const type = options.type ?? 'jpeg';
|
|
19
|
+
const merged = {
|
|
20
|
+
timeout: 60_000,
|
|
21
|
+
scale: 'css',
|
|
22
|
+
...options,
|
|
23
|
+
type,
|
|
24
|
+
};
|
|
25
|
+
if (type === 'jpeg') {
|
|
26
|
+
merged.quality = options.quality ?? 80;
|
|
27
|
+
delete merged.omitBackground;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
delete merged.quality;
|
|
31
|
+
}
|
|
32
|
+
return page.screenshot(merged);
|
|
14
33
|
}
|
|
15
34
|
//# sourceMappingURL=screenshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/helpers/screenshot.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/helpers/screenshot.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAAU,EACV,UAAiC,EAAE;IAEnC,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC;IACpC,MAAM,MAAM,GAA0B;QACpC,OAAO,EAAE,MAAM;QACf,KAAK,EAAE,KAAK;QACZ,GAAG,OAAO;QACV,IAAI;KACL,CAAC;IACF,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QACvC,OAAO,MAAM,CAAC,cAAc,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC"}
|