Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

test(extension): run capture bundle check in isolated Vite process

tianma-if2b519bfc96e4
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();