Matchers are the assertion engine at the heart of KT Testing Suite Core. Every test assertion begins withDocumentation 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.
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
| Matcher | Category | One-line description |
|---|---|---|
toBe(expected) | Equality | Strict identity check (===) |
toEqual(expected) | Equality | Deep equality via JSON.stringify |
toBeDefined() | Type Checks | Value is not undefined |
toBeUndefined() | Type Checks | Value is strictly undefined |
toBeNull() | Type Checks | Value is strictly null |
toBeNumber() | Type Checks | Value is a number and not NaN |
toBeNaN() | Type Checks | Value is NaN |
toBeString() | Type Checks | Value is a string |
toBeBoolean() | Type Checks | Value is a boolean |
toBeFunction() | Type Checks | Value is a function |
toBeArray() | Type Checks | Value is an Array |
toBeInstanceOf(ctor) | Type Checks | Value is an instance of the given constructor |
toBeTrue() | Type Checks | Value is strictly true |
toBeFalse() | Type Checks | Value is strictly false |
toBeTruthy() | Type Checks | Value is truthy (!!value === true) |
toBeFalsy() | Type Checks | Value is falsy (!value === true) |
toBeEmpty() | Collections | Array or string (or null/undefined) has length 0 |
toHaveLength(n) | Collections | Array or string has exactly n elements/characters |
toContain(str) | Collections | String contains the given substring |
toInclude(item) | Collections | Array contains the given element (strict equality) |
toHaveProperty(key, val?) | Collections | Object has own property; optionally checks value |
toPassAny(conditions) | Collections | At least one condition in the array passes |
toBeGreaterThan(n) | Numeric | Number is strictly greater than n |
toBeLessThan(n) | Numeric | Number is strictly less than n |
toBeGreaterThanOrEqual(n) | Numeric | Number is greater than or equal to n |
toBeLessThanOrEqual(n) | Numeric | Number is less than or equal to n |
toBeCloseTo(n, precision?) | Numeric | Floating-point value within 10^-precision of n |
toThrow() | Type Checks | Function throws when called |
toBeFile() | IO | Value is an ExtendScript File instance |
toBeFolder() | IO | Value is an ExtendScript Folder instance |
toBeFileOrFolder() | IO | Value is either a File or a Folder instance |
fileExists() | IO | Value is a File and its .exists property is true |
not() | Negation | Toggles the inverted flag; inverts subsequent matcher assertions |
Chainability
Because every matcher returnsthis, you can assert multiple conditions on a single Expect<T> instance in one expression:
The not() modifier
Prepend not() anywhere in a chain to invert the assertion that follows:
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.