perf(test): cut setup/import overhead in hot suites

This commit is contained in:
Peter Steinberger
2026-02-13 21:23:44 +00:00
parent 93dd51bce0
commit caebe70e9a
16 changed files with 428 additions and 426 deletions

View File

@@ -28,10 +28,7 @@ const sessionMocks = vi.hoisted(() => ({
}));
vi.mock("./pw-session.js", () => sessionMocks);
async function importModule() {
return await import("./pw-tools-core.js");
}
const mod = await import("./pw-tools-core.js");
describe("pw-tools-core", () => {
beforeEach(() => {
@@ -57,7 +54,6 @@ describe("pw-tools-core", () => {
screenshot: vi.fn(async () => Buffer.from("P")),
};
const mod = await importModule();
const res = await mod.takeScreenshotViaPlaywright({
cdpUrl: "http://127.0.0.1:18792",
targetId: "T1",
@@ -78,7 +74,6 @@ describe("pw-tools-core", () => {
screenshot: vi.fn(async () => Buffer.from("P")),
};
const mod = await importModule();
const res = await mod.takeScreenshotViaPlaywright({
cdpUrl: "http://127.0.0.1:18792",
targetId: "T1",
@@ -99,8 +94,6 @@ describe("pw-tools-core", () => {
screenshot: vi.fn(async () => Buffer.from("P")),
};
const mod = await importModule();
await expect(
mod.takeScreenshotViaPlaywright({
cdpUrl: "http://127.0.0.1:18792",
@@ -127,7 +120,6 @@ describe("pw-tools-core", () => {
keyboard: { press: vi.fn(async () => {}) },
};
const mod = await importModule();
await mod.armFileUploadViaPlaywright({
cdpUrl: "http://127.0.0.1:18792",
targetId: "T1",
@@ -151,7 +143,6 @@ describe("pw-tools-core", () => {
keyboard: { press },
};
const mod = await importModule();
await mod.armFileUploadViaPlaywright({
cdpUrl: "http://127.0.0.1:18792",
paths: [],