Skip to content

addThrownMessage

.addThrownMessage()

Tests that the tested callable throws an exception.

throwSomething - accepts any Throwable including Error/AssertError

Examples

With Negation

expect({}).not.to.throwException!Exception.withMessage.equal("test");

What Failures Look Like

When the assertion fails, you’ll see a clear error message:

// This would fail:
expect({}).to.throwException!Exception.withMessage.equal("test");

Modifiers

This assertion supports the following modifiers:

  • .not - Negates the assertion
  • .to - Language chain (no effect)
  • .be - Language chain (no effect)