




















@@ -26,30 +26,26 @@ type ControlRect = {
2626display?: string;
2727};
282829+function expectFiniteRect(rect: Pick<ControlRect, "x" | "y" | "width" | "height">) {
30+for (const key of ["x", "y", "width", "height"] as const) {
31+expect(Number.isFinite(rect[key])).toBe(true);
32+}
33+}
34+2935async function getBoundingBox(page: Page, selector: string) {
3036const box = await page.locator(selector).boundingBox();
31-expect(box).toMatchObject({
32-x: expect.any(Number),
33-y: expect.any(Number),
34-width: expect.any(Number),
35-height: expect.any(Number),
36-});
3737if (box === null) {
3838throw new Error(`Expected bounding box for ${selector}`);
3939}
40+expectFiniteRect(box);
4041return box;
4142}
42434344function expectControlRect(rect: ControlRect | null, label: string): ControlRect {
44-expect(rect).toMatchObject({
45-x: expect.any(Number),
46-y: expect.any(Number),
47-width: expect.any(Number),
48-height: expect.any(Number),
49-});
5045if (rect === null) {
5146throw new Error(`Expected ${label} control rect`);
5247}
48+expectFiniteRect(rect);
5349return rect;
5450}
5551此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。