Ctrl K
ComunidadGuías…

test/scripts/screenshots-readiness.test.ts

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
import { expect } from "@std/expect";
import { describe, it as test } from "@std/testing/bdd";
import { waitForScreenshotPage } from "#scripts/screenshots/readiness.ts";

describe("screenshot page readiness", () => {
  test("waits for resources, requests, fonts, and two browser paints in order", async () => {
    const calls: string[] = [];
    await waitForScreenshotPage({
      evaluate: (expression) => {
        calls.push(expression);
        return Promise.resolve();
      },
      waitForFunction: (expression) => {
        calls.push(expression);
        return Promise.resolve();
      },
      waitForLoadState: (state) => {
        calls.push(state);
        return Promise.resolve();
      },
    });

    expect(calls).toEqual([
      "load",
      "networkidle",
      'document.fonts.status === "loaded"',
      `new Promise((resolve) =>
  requestAnimationFrame(() => requestAnimationFrame(resolve)))`,
    ]);
  });
});