MCPcopy Create free account
hub / github.com/anus-dev/ANUS / createFailingFunction

Function createFailingFunction

packages/core/src/utils/retry.test.ts:14–29  ·  view source on GitHub ↗
(
  failures: number,
  successValue: string = 'success',
)

Source from the content-addressed store, hash-verified

12
13// Helper to create a mock function that fails a certain number of times
14const createFailingFunction = (
15 failures: number,
16 successValue: string = 'success',
17) => {
18 let attempts = 0;
19 return vi.fn(async () => {
20 attempts++;
21 if (attempts <= failures) {
22 // Simulate a retryable error
23 const error: HttpError = new Error(`Simulated error attempt ${attempts}`);
24 error.status = 500; // Simulate a server error
25 throw error;
26 }
27 return successValue;
28 });
29};
30
31// Custom error for testing non-retryable conditions
32class NonRetryableError extends Error {

Callers 1

retry.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected