mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
test(server): src/config takes fixed test values from the setup file, so suites stop mocking it
tests/setup.ts mocks src/config once with tests/helpers/test-config.ts. A suite that needs other values calls overrideTestConfig(), and the setup file restores the defaults after every case. The 191 per-file factories are gone; config.test.ts takes the real module through vi.unmock, and the few suites that signed tokens with their own literal secret read it from TEST_CONFIG.
This commit is contained in:
@@ -2,6 +2,10 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
|
||||
// The subject here is config.ts itself, so this suite takes the real module
|
||||
// rather than the fixed values the global setup puts in its place.
|
||||
vi.unmock('../../src/config');
|
||||
|
||||
// config.ts resolves its key material at import time, so every case here has to
|
||||
// reset the module registry and re-import it with the file system stubbed out.
|
||||
const ENC_KEY_FILE = path.resolve(__dirname, '../../data/.encryption_key');
|
||||
|
||||
Reference in New Issue
Block a user