@letsrunit/playwright 0.1.0 → 0.2.6
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 +3 -2
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/package.json +19 -9
- package/src/field/calendar.ts +1 -2
- package/src/field/native-select.ts +1 -2
- package/src/screenshot.ts +8 -1
- package/src/scrub-html.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Browser, BrowserContextOptions, Page, Locator, PageScreenshotOptions } from '@playwright/test';
|
|
1
|
+
import { Browser, BrowserContextOptions, Page, Locator, LocatorScreenshotOptions, PageScreenshotOptions } from '@playwright/test';
|
|
2
2
|
import { Scalar, Range } from '@letsrunit/utils';
|
|
3
3
|
|
|
4
4
|
declare function browse(browser: Browser, options?: BrowserContextOptions): Promise<Page>;
|
|
@@ -65,6 +65,7 @@ interface PageInfo {
|
|
|
65
65
|
|
|
66
66
|
declare function snapshot(page: Page): Promise<Snapshot>;
|
|
67
67
|
|
|
68
|
+
declare function screenshotElement(page: Page, selector: string, options?: LocatorScreenshotOptions): Promise<File>;
|
|
68
69
|
declare function screenshot(page: Page, options?: PageScreenshotOptions): Promise<File>;
|
|
69
70
|
|
|
70
71
|
declare function scrollToCenter(locator: Locator): Promise<void>;
|
|
@@ -103,4 +104,4 @@ declare function waitAfterInteraction(page: Page, target: Locator, opts?: {
|
|
|
103
104
|
quietMs?: number;
|
|
104
105
|
}): Promise<void>;
|
|
105
106
|
|
|
106
|
-
export { type PageInfo, type Snapshot, browse, createDateEngine, createFieldEngine, formatDate, formatDateForInput, formatHtml, getMonthNames, locator, screenshot, scrollToCenter, setFieldValue, snapshot, suppressInterferences, waitAfterInteraction, waitForAnimationsToFinish, waitForDomIdle, waitForIdle, waitForMeta, waitForUrlChange, waitUntilEnabled };
|
|
107
|
+
export { type PageInfo, type Snapshot, browse, createDateEngine, createFieldEngine, formatDate, formatDateForInput, formatHtml, getMonthNames, locator, screenshot, screenshotElement, scrollToCenter, setFieldValue, snapshot, suppressInterferences, waitAfterInteraction, waitForAnimationsToFinish, waitForDomIdle, waitForIdle, waitForMeta, waitForUrlChange, waitUntilEnabled };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getWeekNumber, sleep, chain, hashKey, isRange, isDate, isArray, cartesian } from '@letsrunit/utils';
|
|
2
|
-
import { diffArray, uniqueItem } from '@letsrunit/utils/src/array';
|
|
1
|
+
import { getWeekNumber, sleep, chain, hashKey, isRange, isDate, isArray, diffArray, cartesian, uniqueItem } from '@letsrunit/utils';
|
|
3
2
|
import rehypeFormat from 'rehype-format';
|
|
4
3
|
import rehypeParse from 'rehype-parse';
|
|
5
4
|
import rehypeStringify from 'rehype-stringify';
|
|
@@ -1412,6 +1411,11 @@ var createFieldEngine = () => ({
|
|
|
1412
1411
|
return candidates.map((el) => ({ el, texts: textFor(el) })).filter(({ texts }) => texts.some(match)).map(({ el }) => el);
|
|
1413
1412
|
}
|
|
1414
1413
|
});
|
|
1414
|
+
async function screenshotElement(page, selector, options) {
|
|
1415
|
+
const buffer = await page.locator(selector).first().screenshot(options);
|
|
1416
|
+
const filename = await hashKey("screenshot-{hash}.png", buffer);
|
|
1417
|
+
return new File([new Uint8Array(buffer)], filename, { type: "image/png" });
|
|
1418
|
+
}
|
|
1415
1419
|
async function screenshot(page, options) {
|
|
1416
1420
|
const buffer = options?.mask?.length ? await screenshotWithMask(page, options) : await page.screenshot(options);
|
|
1417
1421
|
const filename = await hashKey(`screenshot-{hash}.png`, buffer);
|
|
@@ -3001,6 +3005,6 @@ async function suppressInterferences(page, opts = {}) {
|
|
|
3001
3005
|
}
|
|
3002
3006
|
}
|
|
3003
3007
|
|
|
3004
|
-
export { browse, createDateEngine, createFieldEngine, formatDate, formatDateForInput, formatHtml, getMonthNames, locator, screenshot, scrollToCenter, setFieldValue, snapshot, suppressInterferences, waitAfterInteraction, waitForAnimationsToFinish, waitForDomIdle, waitForIdle, waitForMeta, waitForUrlChange, waitUntilEnabled };
|
|
3008
|
+
export { browse, createDateEngine, createFieldEngine, formatDate, formatDateForInput, formatHtml, getMonthNames, locator, screenshot, screenshotElement, scrollToCenter, setFieldValue, snapshot, suppressInterferences, waitAfterInteraction, waitForAnimationsToFinish, waitForDomIdle, waitForIdle, waitForMeta, waitForUrlChange, waitUntilEnabled };
|
|
3005
3009
|
//# sourceMappingURL=index.js.map
|
|
3006
3010
|
//# sourceMappingURL=index.js.map
|