Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vitest/expect

Package Overview
Dependencies
Maintainers
4
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitest/expect

Jest's expect matchers as a Chai plugin

  • 3.0.0-beta.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10M
decreased by-0.88%
Maintainers
4
Weekly downloads
 
Created

What is @vitest/expect?

The @vitest/expect package is a part of the Vitest testing framework, designed to work seamlessly with its ecosystem. It provides a powerful expectation library that allows developers to write assertions for their tests. This package is particularly useful for unit and integration testing, offering a wide range of matchers and utilities to test the behavior of JavaScript code.

What are @vitest/expect's main functionalities?

Basic Expectations

Allows for basic equality checks, useful for asserting that a value matches an expected result.

expect(value).toBe(42);

Object and Array Matching

Enables deep equality checks for objects and arrays, as well as checking for the presence of an item in an array.

expect(object).toEqual({ key: 'value' });
expect(array).toContain(item);

Asynchronous Testing

Facilitates testing of asynchronous operations, allowing assertions on resolved values of promises.

await expect(Promise.resolve('value')).resolves.toBe('value');

Mocking and Spies

Supports the creation of mock functions and spies, enabling the testing of function calls and their arguments.

const mockFunction = vi.fn();
expect(mockFunction).toHaveBeenCalledTimes(1);

Other packages similar to @vitest/expect

FAQs

Package last updated on 05 Dec 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc