mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 20:56:26 +02:00
test(server): integration database not initialized properly
This commit is contained in:
@@ -18,8 +18,13 @@ process.env.TRILIUM_ENV = "dev";
|
||||
process.env.TRILIUM_PUBLIC_SERVER = "http://localhost:4200";
|
||||
|
||||
beforeAll(async () => {
|
||||
// Load the integration test database into memory. The fixture at
|
||||
// spec/db/document.db is pre-seeded with the schema, demo content, and
|
||||
// a known password ("demo1234") that the ETAPI tests log in with. Each
|
||||
// test file runs in its own vitest fork (pool: "forks"), so each gets a
|
||||
// fresh in-memory copy and mutations don't leak across files.
|
||||
const dbProvider = new BetterSqlite3Provider();
|
||||
dbProvider.loadFromMemory();
|
||||
dbProvider.loadFromBuffer(readFileSync(join(__dirname, "db", "document.db")));
|
||||
|
||||
await initializeCore({
|
||||
dbConfig: {
|
||||
|
||||
@@ -13,7 +13,14 @@ export default defineConfig(() => ({
|
||||
env: {
|
||||
NODE_ENV: "development",
|
||||
TRILIUM_DATA_DIR: "./spec/db",
|
||||
TRILIUM_INTEGRATION_TEST: "memory"
|
||||
TRILIUM_INTEGRATION_TEST: "memory",
|
||||
// Must be set in the vitest env (not in spec/setup.ts) so import-time
|
||||
// constants like `isDev` in apps/server/src/services/utils.ts evaluate
|
||||
// correctly. setup.ts top-level statements run AFTER its static imports
|
||||
// resolve, so any env var assigned there is too late for module-load
|
||||
// constants in transitively-imported files.
|
||||
TRILIUM_ENV: "dev",
|
||||
TRILIUM_PUBLIC_SERVER: "http://localhost:4200"
|
||||
},
|
||||
include: ['{src,spec}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
||||
exclude: [
|
||||
|
||||
Reference in New Issue
Block a user