Skip to main content

@rbxts/expect > Assertion > throws

Assertion.throws() method​

Asserts that the function throws an exception that contains the string substring.

Signature:

throws(substring: string): Assertion<T>;

Parameters​

Parameter

Type

Description

substring

string

Returns:

Assertion<T>

Remarks​

For pattern matching, use throwsMatch instead.

Type alias for the throw version of this.

Example​

expect(buyPet).to.be.a.function().that.throws("Not enough money");