also looking at this
test: stop leaking mocked module state across test files
#2274
8 files
+77
-67
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import type { MultiProxyConfig } from '../src/types' |
| 2 | import { describe, expect, it, spyOn } from 'bun:test' | |
| 2 | import { afterEach, describe, expect, it, mock, spyOn } from 'bun:test' | |
| 3 | 3 | import * as Start from '../src/start' |
| 4 | 4 | |
| 5 | 5 | /** |
| @@ -21,6 +21,14 @@ import * as Start from '../src/start' | ||
| 21 | 21 | * single-proxy-in-multi-array tests once this passthrough is corrected). |
| 22 | 22 | */ |
| 23 | 23 | describe('startProxies non-shared-listener fallback passes loadBalancer through', () => { |
| 24 | // This file already defends against spies leaking IN (see the comment on the | |
| 25 | // spy below); without this it leaked right back OUT. `Start.startServer` is a | |
| 26 | // shared export and `spyOn` does not auto-restore, so the no-op stub — and its | |
| 27 | // call history — reached every later file (#2270). | |
| 28 | afterEach(() => { | |
| 29 | mock.restore() | |
| 30 | }) | |
| 31 | ||
| 24 | 32 | it('a single-entry `proxies` array (no shared listener) forwards loadBalancer to startServer', async () => { |
| 25 | 33 | // Matches this file's established convention (see start.test.ts): re-spy |
| 26 | 34 | // immediately before the call and inspect the most recent call, since |