ReviewOS

also looking at this

stacks/rpx

test: stop leaking mocked module state across test files

#2274
Merged glennmichael123 wants to merge fix/2270-2271-test-state-leaks into main
8 files +77 -67
packages/rpx/test/start-on-demand.test.tsmodified+9-1
Changes to packages/rpx/test/start-on-demand.test.ts
@@ -9,7 +9,7 @@
99 * redirect server (challenge store + reactive issuance kick), and serves the
1010 * manager's live SNI set on the shared :443 listener.
1111 */
12import { afterEach, describe, expect, it, spyOn } from 'bun:test'
12import { afterEach, describe, expect, it, mock, spyOn } from 'bun:test'
1313import * as fsp from 'node:fs/promises'
1414import * as os from 'node:os'
1515import * as path from 'node:path'
@@ -21,6 +21,14 @@ const HTTPS_PORT = 49443
2121const HTTP_PORT = 49080
2222const REDIRECT_PORT = 49081
2323
24// File-level, outside both describes: the spies below are restored only after
25// their assertions, so a throw left them installed (#2270). The second describe
26// needs the REAL startHttpRedirectServer, and other files spy this same
27// namespace, so restore globally between every test in this file.
28afterEach(() => {
29 mock.restore()
30})
31
2432describe('startProxies on-demand TLS wiring', () => {
2533 let dir: string | undefined
2634