
@ariestools/vitest-matchers

Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Install
Using npm:
npm install {{name}}
Using yarn:
yarn add {{name}}
Using pnpm:
pnpm add {{name}}
Using bun:
bun add {{name}}
License
See the LICENSE file for license rights and limitations (LGPL-3.0-only).
Reference
packages
vitest-matchers
### .temp-typedoc
### interfaces
### <a id="ExpectationResult"></a>ExpectationResult
@ariestools/vitest-matchers
Result returned by a custom matcher function.
Properties
actual?
optional actual?: unknown;
The actual value received by the matcher.
expected?
optional expected?: unknown;
The expected value the matcher compared against.
message
message: () => string;
Returns a human-readable failure or negation message.
Returns
string
pass
pass: boolean;
Whether the matcher assertion passed.
### variables
### <a id="matchers"></a>matchers
@ariestools/vitest-matchers
const matchers: object;
Collection of custom Vitest matchers extending the built-in expect assertions.
Type Declaration
toBeArrayOfSize()
toBeArrayOfSize(received, expectedSize): ExpectationResult;
Asserts the received value is an array with the specified length.
Parameters
received
unknown
The value to check.
expectedSize
number
The expected array length.
Returns
ExpectationResult
toBeArray()
toBeArray(received): ExpectationResult;
Asserts the received value is an array.
Parameters
received
unknown
The value to check.
Returns
ExpectationResult
toBeOneOf()
toBeOneOf(received, expected): ExpectationResult;
Asserts the received value is one of the values in the expected array.
Parameters
received
unknown
The value to check.
expected
unknown[]
The array of acceptable values.
Returns
ExpectationResult
toBeNegative()
toBeNegative(received): ExpectationResult;
Asserts the received number is negative (less than zero).
Parameters
received
number
The number to check.
Returns
ExpectationResult
toBePositive()
toBePositive(received): ExpectationResult;
Asserts the received number is positive (greater than zero).
Parameters
received
number
The number to check.
Returns
ExpectationResult
toBeNumber
toBeNumber: (received) => ExpectationResult;
Asserts the received value is of type number and not NaN.
Parameters
received
unknown
The value to check.
Returns
ExpectationResult
toBeFunction
toBeFunction: (received) => ExpectationResult;
Asserts the received value is of type function.
Parameters
received
unknown
The value to check.
Returns
ExpectationResult
toBeString
toBeString: (received) => ExpectationResult;
Asserts the received value is of type string.
Parameters
received
unknown
The value to check.
Returns
ExpectationResult
toBeObject()
toBeObject(received): ExpectationResult;
Asserts the received value is a plain object (not an array or null).
Parameters
received
unknown
The value to check.
Returns
ExpectationResult
toBeInteger()
toBeInteger(received): ExpectationResult;
Asserts the received number is an integer.
Parameters
received
number
The number to check.
Returns
ExpectationResult
toBeFalse()
toBeFalse(received): ExpectationResult;
Asserts the received value is strictly false.
Parameters
received
unknown
The value to check.
Returns
ExpectationResult
toBeTrue()
toBeTrue(received): ExpectationResult;
Asserts the received value is strictly true.
Parameters
received
unknown
The value to check.
Returns
ExpectationResult
toContainAllValues()
toContainAllValues(received, expectedValues): object;
Asserts that all expected values are present in the received array or object values.
Parameters
received
unknown
The array or object to check.
expectedValues
unknown[]
The values that must all be present.
Returns
object
pass
pass: boolean = false;
message
message: () => string;
Returns
string
toContainKey()
toContainKey(received, key): object;
Asserts that the received object contains the specified key.
Parameters
received
object
The object to check.
key
string
The key that should be present.
Returns
object
pass
pass: boolean = true;
message
message: () => string;
Returns
string
toInclude()
toInclude(received, value): object;
Asserts that the received array, string, or object values include the specified value.
Parameters
received
unknown
The array, string, or object to search within.
value
any
The value to look for.
Returns
object
pass
pass: boolean;
message
message: () => string;
Returns
string
toIncludeAllMembers()
toIncludeAllMembers(received, expected): ExpectationResult;
Asserts that the received array includes all members of the expected array.
Parameters
received
unknown[]
The array to check.
expected
unknown[]
The members that must all be present.
Returns
ExpectationResult
toContainAllKeys()
toContainAllKeys(received, expectedKeys): ExpectationResult;
Asserts that the received object contains all of the specified keys.
Parameters
received
object
The object to check.
expectedKeys
string[]
The keys that must all be present.
Returns
ExpectationResult
toContainValues()
toContainValues(received, expectedValues): ExpectationResult;
Asserts that the received object contains all of the specified values (using deep equality).
Parameters
received
object
The object to check.
expectedValues
unknown[]
The values that must all be present.
Returns
ExpectationResult
toBeEmpty()
toBeEmpty(received): ExpectationResult;
Asserts the received value is empty (zero-length array/string, empty object, or empty Map/Set).
Parameters
received
unknown
The value to check.
Returns
ExpectationResult
toBeValidDate()
toBeValidDate(received): object;
Asserts the received value is a valid Date instance (not an invalid date).
Parameters
received
unknown
The value to check.
Returns
object
pass
pass: boolean = isValid;
message
message: () => string;
Returns
string
Credits
Made with 🔥 and ❄️ by XY Labs