From 8802612ed09d4e4cd35a22267afd44b20ef9b0fb Mon Sep 17 00:00:00 2001 From: margaretjgu Date: Fri, 29 May 2026 14:22:15 -0400 Subject: [PATCH] test: isolate store singleton from cross-file bun leaks --- test/config/store.test.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/config/store.test.ts b/test/config/store.test.ts index cc96fdaf..d3052007 100644 --- a/test/config/store.test.ts +++ b/test/config/store.test.ts @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, afterEach } from 'node:test' +import { describe, it, beforeEach, afterEach } from 'node:test' import assert from 'node:assert/strict' -import { setResolvedConfig, getResolvedConfig } from '../../src/config/store.ts' +import { setResolvedConfig, getResolvedConfig, _testResetConfig } from '../../src/config/store.ts' import type { ResolvedConfig } from '../../src/config/types.ts' const sampleConfig: ResolvedConfig = { @@ -14,9 +14,15 @@ const sampleConfig: ResolvedConfig = { }, } +// The store is a module-level singleton. Under `bun test` all files share one +// process, so other suites can leave state behind; reset before each test (not +// just after) so assertions about the initial state are order-independent. +beforeEach(() => { + _testResetConfig() +}) + afterEach(() => { - // reset singleton state between tests - setResolvedConfig(undefined as unknown as ResolvedConfig) + _testResetConfig() }) describe('store', () => {