From 2b519bfc96e47c573bf23000bd84f1016a04d098 Mon Sep 17 00:00:00 2001 From: tianma-if Date: Sun, 4 Oct 2026 18:35:36 +0800 Subject: [PATCH] test(extension): run capture bundle check in isolated Vite process --- apps/extension/capture-bundle.test.mjs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/extension/capture-bundle.test.mjs b/apps/extension/capture-bundle.test.mjs index 37f5d895..98b8c3b5 100644 --- a/apps/extension/capture-bundle.test.mjs +++ b/apps/extension/capture-bundle.test.mjs @@ -1,19 +1,27 @@ import { expect, test } from "bun:test"; +import { execFile } from "node:child_process"; import { mkdtemp, readFile, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; +import { promisify } from "node:util"; import { Script } from "node:vm"; import { fileURLToPath } from "node:url"; -import { build } from "vite"; + +const execFileAsync = promisify(execFile); test("the injected page capture is a standalone classic script", async () => { const outDir = await mkdtemp(join(tmpdir(), "edgeever-capture-")); try { - await build({ - configFile: fileURLToPath(new URL("./vite.config.ts", import.meta.url)), - logLevel: "silent", - build: { outDir }, - }); + await execFileAsync(process.execPath, [ + fileURLToPath(new URL("../../node_modules/vite/bin/vite.js", import.meta.url)), + "build", + "--config", + fileURLToPath(new URL("./vite.config.ts", import.meta.url)), + "--outDir", + outDir, + "--logLevel", + "silent", + ]); const capture = await readFile(join(outDir, "assets/capture.js"), "utf8"); expect(() => new Script(capture)).not.toThrow();