Expect
Harness uses Vitest's expect function for making assertions in your tests. The API is 100% compatible with Vitest's expect functionality.
Basic Usage
Soft Assertions
Use expect.soft to continue test execution even when assertions fail:
Complete API Reference
Harness provides the complete Vitest expect API including:
- Basic matchers:
toBe,toEqual,toStrictEqual - Truthiness:
toBeTruthy,toBeFalsy,toBeNull,toBeUndefined,toBeDefined - Numbers:
toBeGreaterThan,toBeLessThan,toBeCloseTo - Strings:
toMatch,toContain,toHaveLength - Arrays/Objects:
toContain,toHaveProperty,toMatchObject - Exceptions:
toThrow,toThrowError - Types:
toBeInstanceOf,toBeTypeOf - Asymmetric matchers:
expect.anything(),expect.any(),expect.arrayContaining(), etc.
For the complete documentation of all available matchers and advanced features, please refer to the Vitest expect documentation.
