Files
2026-05-27 23:47:53 +01:00

41 lines
1.3 KiB
TypeScript

import { readFile } from "node:fs/promises";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
const here = dirname(fileURLToPath(import.meta.url));
const distRoot = resolve(here, "..", "dist");
async function distExists(): Promise<boolean> {
try {
await readFile(resolve(distRoot, "index.js"), "utf8");
return true;
} catch {
return false;
}
}
async function readDist(rel: string): Promise<string> {
return readFile(resolve(distRoot, rel), "utf8");
}
describe("tree-shake guards", () => {
it("page-object subpath does not pull config", {
timeout: 10000,
}, async () => {
if (!(await distExists())) return;
const text = await readDist("page-objects/page-object.js");
expect(text).not.toMatch(/createPlaywrightConfig/);
expect(text).not.toMatch(/waitForNetworkIdle/);
});
it("wait-for-network-idle does not pull dialog helper", {
timeout: 10000,
}, async () => {
if (!(await distExists())) return;
const text = await readDist("helpers/wait-for-network-idle.js");
expect(text).not.toMatch(/dismissDialog/);
expect(text).not.toMatch(/mockGeolocation/);
});
});