Use this file to discover all available pages before exploring further.
Numeric comparison matchers let you assert the relative size of values rather than exact equality. They are useful when testing computed results, thresholds, or any value that should fall within a certain range. All five matchers share the same guard logic: the actual value must be a genuine number type and must not be NaN, otherwise the assertion fails immediately regardless of the comparison operator.
Asserts that the actual value is greater than or equal to the expected value. This is the non-strict counterpart to toBeGreaterThan — equal values pass.
// ✅ Passes — both greater and equal casesexpect(5).toBeGreaterThanOrEqual(3);expect(5).toBeGreaterThanOrEqual(5);// ❌ Throws — actual is lessexpect(() => expect(3).toBeGreaterThanOrEqual(5)).toThrow();
Asserts that the actual value is less than or equal to the expected value. Equal values pass.
// ✅ Passes — both less and equal casesexpect(3).toBeLessThanOrEqual(5);expect(5).toBeLessThanOrEqual(5);// ❌ Throws — actual is greaterexpect(() => expect(10).toBeLessThanOrEqual(5)).toThrow();
The default precision is 6, which means the difference must be less than 0.000001. This matcher exists specifically to handle floating-point arithmetic in ExtendScript, where operations like 0.1 + 0.2 do not produce exactly 0.3.
Use toBeCloseTo instead of toBe whenever you are asserting the result of floating-point arithmetic. Even simple additions like 0.1 + 0.2 produce 0.30000000000000004 in JavaScript, which will cause toBe(0.3) to fail.
Signature:
toBeCloseTo(expected: number, precision?: number): this
Parameter
Type
Default
Description
expected
number
—
The value to compare against.
precision
number
6
Number of decimal places to check. Lower values are more lenient.
The strict comparison matchers (toBeGreaterThan, toBeLessThan) fail when the actual and expected values are equal. The non-strict variants (toBeGreaterThanOrEqual, toBeLessThanOrEqual) pass. This distinction matters when validating boundary conditions:
All numeric comparison matchers guard against NaN and non-number inputs by checking both typeof value === 'number' and !isNaN(value) before performing the comparison. If either check fails the assertion throws regardless of the expected value:
// ❌ All throw — NaN is not a valid number for comparisonexpect(() => expect(NaN).toBeGreaterThan(0)).toThrow();expect(() => expect(NaN).toBeLessThan(0)).toThrow();expect(() => expect(NaN).toBeGreaterThanOrEqual(0)).toThrow();expect(() => expect(NaN).toBeLessThanOrEqual(0)).toThrow();// ❌ All throw — string '5' is not a numberexpect(() => expect('5').toBeGreaterThan(3)).toThrow();expect(() => expect(null).toBeGreaterThan(0)).toThrow();