Expect to throw with Typescript using Bun:test - ts(2348)

typescript, bunjs

2731804.png

Basic Example

  • Be careful on () =>

Async Example

  • Use rejects for Promise

Advanced Usage with Custom Error Types

  • Use new CustomError() instead CustomError to prevent warning

  • Be careful on () =>

Value of type "typeof X' is not callable. Did you mean to include 'new'? ts(2348)

  • To prevent the error shown (it can run as expected) use new AlreadyAdjusted()

jRe9NPT.png
6tNPvSi.png

Last updated

Was this helpful?