Socket
Book a DemoSign in
Socket

@xylabs/vitest-matchers

Package Overview
Dependencies
Maintainers
5
Versions
280
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/vitest-matchers

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

latest
Source
npmnpm
Version
5.0.90
Version published
Weekly downloads
245
94.44%
Maintainers
5
Weekly downloads
 
Created
Source

@xylabs/vitest-matchers

logo

main-build npm-badge npm-downloads-badge jsdelivr-badge npm-license-badge codacy-badge codeclimate-badge snyk-badge socket-badge

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

Reference

@xylabs/vitest-matchers

Interfaces

InterfaceDescription
ExpectationResultResult returned by a custom matcher function.

Variables

VariableDescription
matchersCollection of custom Vitest matchers extending the built-in expect assertions.

interfaces

ExpectationResult

@xylabs/vitest-matchers

Result returned by a custom matcher function.

Properties

PropertyTypeDescription
actual?unknownThe actual value received by the matcher.
expected?unknownThe expected value the matcher compared against.
message() => stringReturns a human-readable failure or negation message.
passbooleanWhether the matcher assertion passed.

variables

matchers

@xylabs/vitest-matchers

const matchers: {
  toBeArrayOfSize: ExpectationResult;
  toBeArray: ExpectationResult;
  toBeOneOf: ExpectationResult;
  toBeNegative: ExpectationResult;
  toBePositive: ExpectationResult;
  toBeNumber: (received: unknown) => ExpectationResult;
  toBeFunction: (received: unknown) => ExpectationResult;
  toBeString: (received: unknown) => ExpectationResult;
  toBeObject: ExpectationResult;
  toBeInteger: ExpectationResult;
  toBeFalse: ExpectationResult;
  toBeTrue: ExpectationResult;
  toContainAllValues: {
     pass: boolean;
     message: () => string;
  };
  toContainKey: {
     pass: boolean;
     message: () => string;
  };
  toInclude: {
     pass: boolean;
     message: () => string;
  };
  toIncludeAllMembers: ExpectationResult;
  toContainAllKeys: ExpectationResult;
  toContainValues: ExpectationResult;
  toBeEmpty: ExpectationResult;
  toBeValidDate: {
     pass: boolean;
     message: () => string;
  };
};

Collection of custom Vitest matchers extending the built-in expect assertions.

Type Declaration

NameTypeDescription
toBeArrayOfSize()(received: unknown, expectedSize: number) => ExpectationResultAsserts the received value is an array with the specified length.
toBeArray()(received: unknown) => ExpectationResultAsserts the received value is an array.
toBeOneOf()(received: unknown, expected: unknown[]) => ExpectationResultAsserts the received value is one of the values in the expected array.
toBeNegative()(received: number) => ExpectationResultAsserts the received number is negative (less than zero).
toBePositive()(received: number) => ExpectationResultAsserts the received number is positive (greater than zero).
toBeNumber()(received: unknown) => ExpectationResultAsserts the received value is of type number and not NaN.
toBeFunction()(received: unknown) => ExpectationResultAsserts the received value is of type function.
toBeString()(received: unknown) => ExpectationResultAsserts the received value is of type string.
toBeObject()(received: unknown) => ExpectationResultAsserts the received value is a plain object (not an array or null).
toBeInteger()(received: number) => ExpectationResultAsserts the received number is an integer.
toBeFalse()(received: unknown) => ExpectationResultAsserts the received value is strictly false.
toBeTrue()(received: unknown) => ExpectationResultAsserts the received value is strictly true.
toContainAllValues()(received: unknown, expectedValues: unknown[]) => { pass: boolean; message: () => string; }Asserts that all expected values are present in the received array or object values.
toContainKey()(received: object, key: string) => { pass: boolean; message: () => string; }Asserts that the received object contains the specified key.
toInclude()(received: unknown, value: any) => { pass: boolean; message: () => string; }Asserts that the received array, string, or object values include the specified value.
toIncludeAllMembers()(received: unknown[], expected: unknown[]) => ExpectationResultAsserts that the received array includes all members of the expected array.
toContainAllKeys()(received: object, expectedKeys: string[]) => ExpectationResultAsserts that the received object contains all of the specified keys.
toContainValues()(received: object, expectedValues: unknown[]) => ExpectationResultAsserts that the received object contains all of the specified values (using deep equality).
toBeEmpty()(received: unknown) => ExpectationResultAsserts the received value is empty (zero-length array/string, empty object, or empty Map/Set).
toBeValidDate()(received: unknown) => { pass: boolean; message: () => string; }Asserts the received value is a valid Date instance (not an invalid date).

Part of sdk-js

Maintainers

License

See the LICENSE file for license details

Credits

Made with 🔥 and ❄️ by XYLabs

Keywords

log

FAQs

Package last updated on 26 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts