The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
import { describe, expect, it, vi } from 'vitest'
import { withTimeout } from './with-timeout'
describe('withTimeout', () => {
it('rejects with an onTimeout exception instead of letting it escape the timer callback', async () => {
vi.useFakeTimers()
try {
const callbackFailure = new Error('abort callback failed')
const result = withTimeout(new Promise<never>(() => undefined), 10, 'work timed out', () => {
throw callbackFailure
})
const rejection = expect(result).rejects.toBe(callbackFailure)
await vi.advanceTimersByTimeAsync(10)
await rejection
} finally {
vi.useRealTimers()
}
})
})