diff --git a/src/db/locator.ts b/src/db/locator.ts index 6ca55fd..1d04f1f 100644 --- a/src/db/locator.ts +++ b/src/db/locator.ts @@ -36,8 +36,7 @@ export function getDb(): Database { if (!testScope) testScope = new AsyncLocalStorage(); const scoped = testScope.getStore(); if (scoped) return scoped; - // En tests, permitir fallback a currentDb si está configurada explícitamente en el hook - if (currentDb) return currentDb; + // En tests, no hacemos fallback a currentDb para evitar contaminación entre suites throw new DbNotConfiguredError('Database has not been configured. Call setDb(db) before using getDb().'); } if (currentDb) return currentDb; @@ -49,10 +48,7 @@ export function getDb(): Database { */ export function resetDb(): void { currentDb = null; - if (process.env.NODE_ENV === 'test') { - // Re-inicializar el almacenamiento para limpiar el store del contexto actual - testScope = new AsyncLocalStorage(); - } + // En tests no tocamos testScope para no invalidar contextos de otras suites en paralelo } /** @@ -60,10 +56,7 @@ export function resetDb(): void { */ export function clearDb(): void { currentDb = null; - if (process.env.NODE_ENV === 'test') { - // Re-inicializar el almacenamiento para limpiar el store del contexto actual - testScope = new AsyncLocalStorage(); - } + // En tests no tocamos testScope para no invalidar contextos de otras suites en paralelo } /**