Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Octopodo/kt-testing-suite-core/llms.txt

Use this file to discover all available pages before exploring further.

Matchers are the assertion engine at the heart of KT Testing Suite Core. Every test assertion begins with expect(value), which returns a typed Expect<T> instance. From there you call a matcher method — such as .toBe(), .toBeString(), or .toHaveLength() — which evaluates the actual value against a condition and either passes silently or throws an error that the test runner records as a failure. Every matcher returns this, the same Expect<T> instance, so you can chain multiple assertions on a single value without repeating expect(...). You can also prepend .not() — called as a function — to invert the assertion. The sections below group all built-in matchers by category and link to dedicated reference pages for each group.
not() must be called as a function with parentheses: expect(x).not().toBe(y). Writing expect(x).not.toBe(y) (without parentheses) will not invert the assertion.

Matcher categories

Equality

toBe for strict identity and toEqual for deep JSON equality.

Type Checks

toBeDefined, toBeNull, toBeString, toBeNumber, toBeArray, toBeTruthy, toThrow, and more.

Numeric

toBeGreaterThan, toBeLessThan, toBeCloseTo, and their variants.

Collections

toBeEmpty, toHaveLength, toContain, toInclude, toHaveProperty, toPassAny.

IO Matchers

toBeFile, toBeFolder, toBeFileOrFolder, and fileExists for ExtendScript IO types.

Negation

The not() modifier and how it interacts with every matcher.

Quick-reference table

MatcherCategoryOne-line description
toBe(expected)EqualityStrict identity check (===)
toEqual(expected)EqualityDeep equality via JSON.stringify
toBeDefined()Type ChecksValue is not undefined
toBeUndefined()Type ChecksValue is strictly undefined
toBeNull()Type ChecksValue is strictly null
toBeNumber()Type ChecksValue is a number and not NaN
toBeNaN()Type ChecksValue is NaN
toBeString()Type ChecksValue is a string
toBeBoolean()Type ChecksValue is a boolean
toBeFunction()Type ChecksValue is a function
toBeArray()Type ChecksValue is an Array
toBeInstanceOf(ctor)Type ChecksValue is an instance of the given constructor
toBeTrue()Type ChecksValue is strictly true
toBeFalse()Type ChecksValue is strictly false
toBeTruthy()Type ChecksValue is truthy (!!value === true)
toBeFalsy()Type ChecksValue is falsy (!value === true)
toBeEmpty()CollectionsArray or string (or null/undefined) has length 0
toHaveLength(n)CollectionsArray or string has exactly n elements/characters
toContain(str)CollectionsString contains the given substring
toInclude(item)CollectionsArray contains the given element (strict equality)
toHaveProperty(key, val?)CollectionsObject has own property; optionally checks value
toPassAny(conditions)CollectionsAt least one condition in the array passes
toBeGreaterThan(n)NumericNumber is strictly greater than n
toBeLessThan(n)NumericNumber is strictly less than n
toBeGreaterThanOrEqual(n)NumericNumber is greater than or equal to n
toBeLessThanOrEqual(n)NumericNumber is less than or equal to n
toBeCloseTo(n, precision?)NumericFloating-point value within 10^-precision of n
toThrow()Type ChecksFunction throws when called
toBeFile()IOValue is an ExtendScript File instance
toBeFolder()IOValue is an ExtendScript Folder instance
toBeFileOrFolder()IOValue is either a File or a Folder instance
fileExists()IOValue is a File and its .exists property is true
not()NegationToggles the inverted flag; inverts subsequent matcher assertions

Chainability

Because every matcher returns this, you can assert multiple conditions on a single Expect<T> instance in one expression:
expect('hello world')
  .toBeString()
  .toHaveLength(11)
  .toContain('world');
Each matcher in the chain is evaluated independently against the original value. A failure in any link throws immediately and the chain stops.

The not() modifier

Prepend not() anywhere in a chain to invert the assertion that follows:
expect(42).not().toBeString();
expect([1, 2, 3]).not().toBeEmpty();
expect(() => { throw new Error(); }).not().not().toThrow(); // double-negation: passes
not() returns the same Expect<T> instance with its internal inverted flag toggled. The flag persists for all subsequent matchers in the chain — call not() again to toggle it back. See the Negation page for the full reference.

Build docs developers (and LLMs) love