Skip to content

Build your personal knowledge base with Trilium Notes

fix(desktop): prevent real electron load from breaking dynamic-import mocks in tests

Elian Dorana9d111eeb360
diff --git a/apps/desktop/vitest.config.mts b/apps/desktop/vitest.config.mts
index 75a80cdabd..0e34e2027e 100644
--- a/apps/desktop/vitest.config.mts
+++ b/apps/desktop/vitest.config.mts
@@ -15,7 +15,14 @@ export default defineConfig(() => ({
// ensures they're in place before static imports resolve.
NODE_ENV: "development",
TRILIUM_INTEGRATION_TEST: "memory",
- TRILIUM_ENV: "dev"
+ TRILIUM_ENV: "dev",
+ // Specs `vi.mock("electron", ...)`, but vitest still *evaluates* the
+ // real electron module when code does a dynamic `await import("electron")`
+ // (window.ts / main.ts). On CI the electron binary isn't installed, so
+ // electron's index.js throws "Electron failed to install correctly".
+ // This override makes index.js return a path instead of throwing; the
+ // mock value is still what the code receives, so the value is never used.
+ ELECTRON_OVERRIDE_DIST_PATH: "/nonexistent/electron-dist-test-override"
},
include: ["src/**/*.spec.ts"],
reporters: [