Skip to content

Commit f55197e

Browse files
committed
add mock note
1 parent 2b7efc8 commit f55197e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/repo-tools/src/test-utils/abort-signal.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import { vi } from 'vitest';
33
/**
44
* Create a mock AbortSignal that can be manually aborted.
55
*
6+
* This utility was created because Vitest cannot mock `AbortSignal.timeout()`.
7+
* Vitest relies on @sinonjs/fake-timers for timer mocking, but fake-timers does
8+
* not implement the AbortSignal.timeout API, so we cannot use Vitest's timer
9+
* mocking to test timeout behavior. This mock allows us to manually trigger
10+
* abort events in tests to simulate timeout scenarios.
11+
* https://github.com/vitest-dev/vitest/issues/3088
12+
*
613
* @param timeoutMs - The timeout value (stored for verification).
714
* @returns A mock AbortSignal.
815
*/

0 commit comments

Comments
 (0)