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

jest-matcher-utils

Package Overview
Dependencies
Maintainers
7
Versions
232
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-matcher-utils

A set of utility functions for expect and related packages

  • 25.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
40M
increased by6.06%
Maintainers
7
Weekly downloads
 
Created

What is jest-matcher-utils?

The jest-matcher-utils package provides utility functions for creating custom Jest matchers. It is designed to help developers write their own matchers that integrate seamlessly with Jest's built-in expectation system, offering a way to extend Jest's assertion capabilities with custom logic. The utilities provided by this package include formatting values for error messages, comparing values, and generating matcher error messages.

What are jest-matcher-utils's main functionalities?

pretty-format

Formats any JavaScript value for pretty printing, which is useful for generating readable error messages in custom matchers.

const { prettyFormat } = require('jest-matcher-utils');
console.log(prettyFormat({ foo: 'bar' }));

matcherHint

Generates a hint string for a matcher, which can be used at the beginning of error messages to indicate which matcher failed.

const { matcherHint } = require('jest-matcher-utils');
console.log(matcherHint('.toBe'));

printExpected and printReceived

These functions format the expected and received values to be included in error messages, applying color highlighting to improve readability.

const { printExpected, printReceived } = require('jest-matcher-utils');
console.log(`Expected: ${printExpected(true)}
Received: ${printReceived(false)}`);

Other packages similar to jest-matcher-utils

FAQs

Package last updated on 28 Apr 2020

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