Commit 297274d
HCL
fix(twitch): export clearRegistryForTest for cross-test isolation (#83887)
`client-manager-registry.ts` holds a module-level `Map<accountId,
RegistryEntry>` for `getOrCreateClientManager`. `TwitchClientManager`
in the sibling module already acknowledges that module-level state
needs a test escape hatch (`clearForTest`), but the registry lacks
the equivalent. Under vitest `--isolate=false` (or any harness that
keeps the module graph hot across tests) a test that calls
`getOrCreateClientManager('default', loggerA)` leaves its entry
behind, and the next test calling the same factory silently gets
loggerA's manager — chasing a phantom mock-assertion bug becomes
the failure mode.
Add an exported `clearRegistryForTest()` that calls `registry.clear()`,
mirroring `TwitchClientManager.clearForTest`. No production behavior
change — production code never calls this.1 parent 48acdd3 commit 297274d
1 file changed
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
0 commit comments