Skip to main content

@rbxts/expect > Assertion > length

Assertion.length() method

Asserts that the value has a length of size.

Signature:

length(size: number): this;

Parameters

Parameter

Type

Description

size

number

The length that the "actual" value should have.

Returns:

this

This instance for chaining.

Remarks

Works with strings or iterable types.

An object's size is measured by its keys.

A string's size is measured by its characters.

An iterable's size is measured by its elements.

Example

expect([1,2,3]).to.have.a.length(3);
expect({ name: "Daymon", age: 5 }).to.have.a.length(2);
expect("Daymon").to.have.a.length(6);