Skip to main content

@rbxts/expect > Assertion > near

Assertion.near() method

Asserts that the actual value is a number within margin of value.

Signature:

near(value: number, margin: number): Assertion<number>;

Parameters

Parameter

Type

Description

value

number

The number that the actual value should be margin of.

margin

number

A range of which the actual value should be +-value in.

Returns:

Assertion<number>

Remarks

The margin is considered inclusive; if the actual value is exactly value +- margin then it's considered a pass.

Example

expect(11).to.be.near(10, 1);
expect(100).to.be.near(125, 50);
expect(5.005).to.be.near(5, .01)