Skip to main content

@rbxts/expect > Assertion > throw

Assertion.throw() method

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

Signature:

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

Parameters

Parameter

Type

Description

substring

string

Returns:

Assertion<T>

Remarks

For pattern matching, use throwMatch instead.

Example

expect(buyPet).to.throw("Failed to buy pet");