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:
When multiple soft assertions fail, Harness reports all failure messages, but currently only the first failure contributes the highlighted stack trace and code frame.
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.
