(shouldThrow: (attempt: number) => boolean)
| 65 | }); |
| 66 | |
| 67 | function mockTablePayloadRangeError(shouldThrow: (attempt: number) => boolean) { |
| 68 | const originalStringify = JSON.stringify; |
| 69 | let tablePayloadAttempts = 0; |
| 70 | |
| 71 | return vi |
| 72 | .spyOn(JSON, 'stringify') |
| 73 | .mockImplementation((...args: Parameters<typeof JSON.stringify>) => { |
| 74 | const value = args[0]; |
| 75 | if (value && typeof value === 'object' && 'table' in value && 'totalCount' in value) { |
| 76 | tablePayloadAttempts += 1; |
| 77 | if (shouldThrow(tablePayloadAttempts)) { |
| 78 | throw new RangeError('Invalid string length'); |
| 79 | } |
| 80 | } |
| 81 | return originalStringify.apply(JSON, args); |
| 82 | }); |
| 83 | } |
| 84 | |
| 85 | async function setResultPromptRaws(eval_: Eval, raws: string[]) { |
| 86 | const results = await eval_.getResults(); |
no outgoing calls
no test coverage detected
searching dependent graphs…