Skip to content

Comparison Operations

Compare numeric values with these assertions.

greaterThan / above

Asserts that a value is greater than the expected value.

expect(42).to.be.greaterThan(10);
expect(42).to.be.above(10); // alias

lessThan / below

Asserts that a value is less than the expected value.

expect(10).to.be.lessThan(42);
expect(10).to.be.below(42); // alias

between

Asserts that a value is between two bounds (exclusive).

expect(42).to.be.between(10, 100);

within

Asserts that a value is within a range (inclusive).

expect(42).to.be.within(40, 45);