trips) adding package-tours option
This commit is contained in:
16
src/tests/helpers.ts
Normal file
16
src/tests/helpers.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { createSqliteDb } from '$lib/server/db/sqlite.js';
|
||||
import { runMigrations } from '$lib/server/db/migrations.js';
|
||||
import { _setDb } from '$lib/server/db/index.js';
|
||||
import type { Database } from '$lib/server/db/types.js';
|
||||
|
||||
/**
|
||||
* Creates a fresh in-memory SQLite database, runs all migrations, and injects
|
||||
* it into the server module singleton. Call in beforeEach; call db.close() in
|
||||
* afterEach to release the in-memory DB.
|
||||
*/
|
||||
export function setupTestDb(): Database {
|
||||
const database = createSqliteDb(':memory:');
|
||||
runMigrations(database);
|
||||
_setDb(database);
|
||||
return database;
|
||||
}
|
||||
3
src/tests/stubs/env.ts
Normal file
3
src/tests/stubs/env.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// Stub for $env/dynamic/private — not available outside SvelteKit at test time.
|
||||
// Tests bypass createDb() entirely via _setDb(), so this is never actually read.
|
||||
export const env: Record<string, string> = {};
|
||||
3
src/tests/stubs/paths.ts
Normal file
3
src/tests/stubs/paths.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// Stub for $app/paths — used by some server helpers for URL construction.
|
||||
export const base = '';
|
||||
export const assets = '';
|
||||
Reference in New Issue
Block a user