Skip to content

Commit d2fb707

Browse files
emilioaccclaude
andcommitted
fix: correct process.exit mocking in workerInfoCommand tests
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent fb0feb2 commit d2fb707

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/atxp/src/commands/paas/worker.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,31 @@ describe('Worker Commands', () => {
291291
expect(console.log).toHaveBeenCalled();
292292
});
293293

294-
it('should exit with error when worker is not found', async () => {
294+
it('should call process.exit when worker is not found', async () => {
295295
const mockResponse = JSON.stringify({
296296
success: false,
297297
error: 'Worker not found',
298298
});
299299
vi.mocked(callTool).mockResolvedValue(mockResponse);
300+
const exitSpy = vi.spyOn(process, 'exit').mockImplementation(() => undefined as never);
301+
302+
await workerInfoCommand('nonexistent-worker');
300303

301-
await expect(workerInfoCommand('nonexistent-worker')).rejects.toThrow('process.exit called');
302304
expect(console.error).toHaveBeenCalled();
305+
expect(exitSpy).toHaveBeenCalledWith(1);
303306
});
304307

305308
it('should handle error response without error message', async () => {
306309
const mockResponse = JSON.stringify({
307310
success: false,
308311
});
309312
vi.mocked(callTool).mockResolvedValue(mockResponse);
313+
const exitSpy = vi.spyOn(process, 'exit').mockImplementation(() => undefined as never);
314+
315+
await workerInfoCommand('my-worker');
310316

311-
await expect(workerInfoCommand('my-worker')).rejects.toThrow('process.exit called');
312317
expect(console.error).toHaveBeenCalled();
318+
expect(exitSpy).toHaveBeenCalledWith(1);
313319
});
314320

315321
it('should fallback to raw output when JSON parsing fails', async () => {

0 commit comments

Comments
 (0)