Skip to content

Commit 791eda4

Browse files
committed
fix: mock process.exit in handleError test to prevent killing test runner
process.exit() was terminating the entire bun test process, preventing subsequent test files from running and causing exit code 5.
1 parent 6b29dbd commit 791eda4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

test/auth/timeout-fix.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,20 @@ describe('handleError: timeout message includes region/auth hint', () => {
199199

200200
let captured = '';
201201
const origWrite = process.stderr.write.bind(process.stderr);
202+
const origExit = process.exit;
202203
(process.stderr as NodeJS.WriteStream).write = (chunk: unknown) => {
203204
captured += String(chunk);
204205
return true;
205206
};
207+
(process as unknown as Record<string, unknown>).exit = () => { throw new Error('exit'); };
206208

207209
try {
208210
handleError(abortErr);
209211
} catch {
210-
// process.exit throws in test env — that's expected
212+
// mocked process.exit throws expected
211213
} finally {
212214
(process.stderr as NodeJS.WriteStream).write = origWrite;
215+
(process as unknown as Record<string, unknown>).exit = origExit;
213216
}
214217

215218
expect(captured).toContain('mmx auth status');

0 commit comments

Comments
 (0)