Skip to content

Commit 55ba015

Browse files
committed
test(mcp): clear the shared SSE collections instead of reassigning globalThis
mcp.ts captures the connections Map and subscribed Set in module consts at import, so setting the globalThis property to undefined didn't reset what the module uses — subscription state leaked across tests. Clear the shared instances instead.
1 parent ced941c commit 55ba015

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

apps/sim/hooks/queries/mcp.test.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@ describe('useMcpToolsQuery', () => {
120120

121121
afterEach(() => {
122122
vi.restoreAllMocks()
123-
;(globalThis as unknown as Record<string, unknown>).__mcp_sse_connections = undefined
124-
;(globalThis as unknown as Record<string, unknown>).__mcp_sse_subscribed = undefined
123+
// mcp.ts captured these Map/Set instances in module consts at import, so reassigning the
124+
// globalThis property wouldn't reset what the module uses — clear the shared instances.
125+
;(
126+
globalThis as unknown as { __mcp_sse_connections?: Map<string, unknown> }
127+
).__mcp_sse_connections?.clear()
128+
;(globalThis as unknown as { __mcp_sse_subscribed?: Set<string> }).__mcp_sse_subscribed?.clear()
125129
})
126130

127131
it('does not auto-discover disconnected or errored OAuth servers', async () => {

0 commit comments

Comments
 (0)