Socket
Socket
Sign inDemoInstall

jest-matcher-utils

Package Overview
Dependencies
0
Maintainers
3
Versions
229
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-matcher-utils

A set of utility functions for jest-matchers and related packages


Version published
Maintainers
3
Install size
4.51 kB
Created

Package description

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

Changelog

Source

jest 14.0.0

  • Official release of snapshot tests.
  • Started to replace Jasmine matchers with Jest matchers: toBe, toBeFalsy, toBeTruthy, toBeNaN, toBe{Greater,Less}Than{,OrEqual}, toBeNull, toBeDefined, toBeUndefined, toContain, toMatch, toBeCloseTo were rewritten.
  • Rewrite of Jest's reporters.
  • Experimental react-native support.
  • Removed Jasmine 1 support from Jest.
  • Transform caching improvements.

FAQs

Last updated on 27 Jul 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc