(promise: Promise<any>, code?: string)
| 1 | import { expect } from 'vitest'; |
| 2 | |
| 3 | export async function assertAsyncError(promise: Promise<any>, code?: string) { |
| 4 | try { |
| 5 | await promise; |
| 6 | } catch (err) { |
| 7 | if (code) { |
| 8 | expect(err.message).toMatch(new RegExp(`^${code}.+`)); |
| 9 | expect(err.code).toBe(code); |
| 10 | } |
| 11 | |
| 12 | return; |
| 13 | } |
| 14 | |
| 15 | throw new Error('Promise did not throw'); |
| 16 | } |
no outgoing calls
no test coverage detected