fix: libs test

This commit is contained in:
Kacper
2026-01-02 20:50:57 +01:00
parent 4a28b70b72
commit e72f7d1e1a

View File

@@ -20,6 +20,7 @@ async function collectAsyncGenerator<T>(generator: AsyncGenerator<T>): Promise<T
describe('subprocess.ts', () => { describe('subprocess.ts', () => {
let consoleSpy: { let consoleSpy: {
log: ReturnType<typeof vi.spyOn>; log: ReturnType<typeof vi.spyOn>;
warn: ReturnType<typeof vi.spyOn>;
error: ReturnType<typeof vi.spyOn>; error: ReturnType<typeof vi.spyOn>;
}; };
@@ -27,12 +28,14 @@ describe('subprocess.ts', () => {
vi.clearAllMocks(); vi.clearAllMocks();
consoleSpy = { consoleSpy = {
log: vi.spyOn(console, 'log').mockImplementation(() => {}), log: vi.spyOn(console, 'log').mockImplementation(() => {}),
warn: vi.spyOn(console, 'warn').mockImplementation(() => {}),
error: vi.spyOn(console, 'error').mockImplementation(() => {}), error: vi.spyOn(console, 'error').mockImplementation(() => {}),
}; };
}); });
afterEach(() => { afterEach(() => {
consoleSpy.log.mockRestore(); consoleSpy.log.mockRestore();
consoleSpy.warn.mockRestore();
consoleSpy.error.mockRestore(); consoleSpy.error.mockRestore();
}); });
@@ -176,11 +179,11 @@ describe('subprocess.ts', () => {
const generator = spawnJSONLProcess(baseOptions); const generator = spawnJSONLProcess(baseOptions);
await collectAsyncGenerator(generator); await collectAsyncGenerator(generator);
expect(consoleSpy.error).toHaveBeenCalledWith( expect(consoleSpy.warn).toHaveBeenCalledWith(
expect.stringContaining('Warning: something happened') expect.stringContaining('[SubprocessManager] stderr: Warning: something happened')
); );
expect(consoleSpy.error).toHaveBeenCalledWith( expect(consoleSpy.warn).toHaveBeenCalledWith(
expect.stringContaining('Error: critical issue') expect.stringContaining('[SubprocessManager] stderr: Error: critical issue')
); );
}); });