79417275

Date: 2025-02-06 08:58:48
Score: 0.5
Natty:
Report link

I ended up adding a little util that catches the error and throws the custom message:

export async function expectToResolve(expected: Promise<any>, msg: string) {
  try {
    await expect(expected, "").resolves.toBeUndefined()
  } catch {
    throw new Error(msg)
  }
}

It can be used like this:

await expectToResolve(promise, "custom message");
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Blee