Socket
Socket
Sign inDemoInstall

jest-matcher-utils

Package Overview
Dependencies
7
Maintainers
3
Versions
230
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
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 15.0.0

  • See https://jestjs.io/blog/2016/09/01/jest-15
  • Jest by default now also recognizes files ending in .spec.js and .test.js as test files.
  • Completely replaced most Jasmine matchers with new Jest matchers.
  • Rewrote Jest's CLI output for test failures and summaries.
  • Added --env option to override the default test environment.
  • Disabled automocking, fake timers and resetting the module registry by default.
  • Added --watchAll, made --watch interactive and added the ability to update snapshots and select test patterns in watch mode.
  • Jest uses verbose mode when running a single test file.
  • Console messages are now buffered and printed along with the test results.
  • Fix testEnvironment resolution to prefer jest-environment-{name} instead of {name} only. This prevents a module collision when using jsdom as test environment.
  • moduleNameMapper now uses a resolution algorithm.
  • Improved performance for small test runs.
  • Improved API documentation.
  • Jest now works properly with directories that have special characters in them.
  • Improvements to Jest's own test infra by merging integration and unit tests. Code coverage is now collected for Jest.
  • Added global.global to the node environment.
  • Fixed babel-jest-plugin-hoist issues with functions called mock.
  • Improved jest-react-native preset with mocks for ListView, TextInput, ActivityIndicator and ScrollView.
  • Added collectCoverageFrom to collect code coverage from untested files.
  • Rewritten code coverage support.

FAQs

Last updated on 31 Aug 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