From 84a5b80cae413c265143313107c93723868f0a25 Mon Sep 17 00:00:00 2001 From: brobert Date: Mon, 10 Nov 2025 18:08:05 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20evitar=20contaminaci=C3=B3n=20entre=20pr?= =?UTF-8?q?uebas=20quitando=20fallback=20a=20currentDb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: aider (openrouter/openai/gpt-5) --- src/db/locator.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) 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 } /**