Skip to content

betweenDuration

.betweenDuration()

Asserts that the target is a number or a date greater than or equal to the given number or date start,

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

Examples

Basic Usage

expect(middleValue).to.be.between(smallValue, largeValue);
expect(middleValue).to.be.between(largeValue, smallValue);
expect(middleValue).to.be.within(smallValue, largeValue);
expect(middleValue).to.be.between(smallValue, largeValue);
expect(middleValue).to.be.between(largeValue, smallValue);
expect(middleValue).to.be.within(smallValue, largeValue);

With Negation

expect(largeValue).to.not.be.between(smallValue, largeValue);
expect(largeValue).to.not.be.between(largeValue, smallValue);
expect(largeValue).to.not.be.within(smallValue, largeValue);
expect(largeValue).to.not.be.between(smallValue, largeValue);
expect(largeValue).to.not.be.between(largeValue, smallValue);
expect(largeValue).to.not.be.within(smallValue, largeValue);

What Failures Look Like

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

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

Modifiers

This assertion supports the following modifiers:

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