Skip to content

lessOrEqualToDuration

.lessOrEqualToDuration()

Asserts that the tested value is less or equal than the tested value. However, it’s often best to assert that the target is equal to its expected value.

Examples

Basic Usage

expect(smallValue).to.be.lessOrEqualTo(largeValue);
expect(smallValue).to.be.lessOrEqualTo(smallValue);
expect(smallValue).to.be.lessOrEqualTo(largeValue);
expect(smallValue).to.be.lessOrEqualTo(smallValue);

With Negation

expect(largeValue).not.to.be.lessOrEqualTo(smallValue);
expect(largeValue).not.to.be.lessOrEqualTo(smallValue);

What Failures Look Like

When the assertion fails, you’ll see a clear error message:

// This would fail:
expect(largeValue).to.be.lessOrEqualTo(smallValue);

Modifiers

This assertion supports the following modifiers:

  • .not - Negates the assertion
  • .to - Language chain (no effect)
  • .be - Language chain (no effect)