Skip to content

Commit 8306969

Browse files
committed
test(coverage): cover setupTelemetryExitHandlers duplicate-call skip
Adds a test for the early-return branch when exitHandlersRegistered is already true (lines 118-119). Calls setupTelemetryExitHandlers twice and asserts that the second call does not register additional process.on handlers. integration.mts: 88.04% → 90.21% statements (87.61% → 89.13% branch).
1 parent 8009259 commit 8306969

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

packages/cli/test/unit/utils/telemetry/integration.test.mts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ describe('telemetry/integration', () => {
146146
expect(processOnSpy).toHaveBeenCalled()
147147
processOnSpy.mockRestore()
148148
})
149+
150+
it('skips re-registration on duplicate calls (lines 118-119)', () => {
151+
// First call registers (or has already registered from a prior test
152+
// in the same module — module-level exitHandlersRegistered persists).
153+
setupTelemetryExitHandlers()
154+
const processOnSpy = vi.spyOn(process, 'on')
155+
// Second call should hit the early-return branch.
156+
setupTelemetryExitHandlers()
157+
// No new handlers registered on the second call.
158+
expect(processOnSpy).not.toHaveBeenCalled()
159+
processOnSpy.mockRestore()
160+
})
149161
})
150162

151163
describe('trackSubprocessExit', () => {

0 commit comments

Comments
 (0)