Skip to main content

@rbxts/expect > Assertion > anyOf

Assertion.anyOf() method

Asserts that the value is shallow equal to any of the provided values.

Signature:

anyOf<R = T>(values: R[]): Assertion<R>;

Parameters

Parameter

Type

Description

values

R[]

An array of values to check for

Returns:

Assertion<R>

Remarks

When used after an enum call, the output message will use the enum key as the value.

Example 1

Basic Usage:

expect(1).to.be.anyOf([1,2,3]);
expect(0).to.not.be.anyOf([1,2,3]);

Example 2

Enum Usage:

enum Sport {
Basketball,
Football,
Soccer
}

expect(Sport.Basketball).to.be.the.enum(Sport).and.to.be.anyOf([Football, Soccer]);
// Expected 'Basketball' (enum/number) to be any of ["Football", "Soccer"]