Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
jest-matcher-utils
Advanced tools
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.
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)}`);
Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework. It offers similar functionality to jest-matcher-utils in the sense that it provides a rich set of assertions and plugins to extend its capabilities. However, Chai is a standalone assertion library, not tied to any specific test runner like Jest.
Expect is a minimalist assertion library that comes with Jest but can also be used independently. It provides a similar API for writing test assertions as jest-matcher-utils, but jest-matcher-utils focuses more on the utilities for creating custom matchers rather than providing a comprehensive set of built-in matchers.
This package's exports are most notably used by expect
's this.utils
.
To add this package as a dependency of a project, run either of the following commands:
npm install jest-matcher-utils
yarn add jest-matcher-utils
stringify
highlightTrailingWhitespace
printReceived
printExpected
printWithType
ensureNoExpected
ensureActualIsNumber
ensureExpectedIsNumber
ensureNumbers
ensureExpectedIsNonNegativeInteger
printDiffOrStringify
diff
pluralize
getLabelPrinter
matcherErrorMessage
matcherHint
MatcherHintOptions
DiffOptions
EXPECTED_COLOR
RECEIVED_COLOR
INVERTED_COLOR
BOLD_WEIGHT
DIM_COLOR
SUGGEST_TO_CONTAIN_EQUAL
27.4.0
[expect]
Enhancing the toHaveProperty
matcher to support array selection (#12092)[jest-core]
Add support for testResultsProcessor
written in ESM (#12006)[jest-diff, pretty-format]
Add compareKeys
option for custom sorting of object keys (#11992)[jest-mock]
Add ts-jest
mock util functions (#12089)[expect]
Allow again expect.Matchers
generic with single value (#11986)[jest-circus, jest-jasmine2]
Avoid false concurrent test failures due to unhandled promise rejections (#11987)[jest-config]
Add missing slash
dependency to package.json
(#12080)[jest-core]
Incorrect detection of open ZLIB handles (#12022)[jest-diff]
Break dependency cycle (#10818)[jest-environment-jsdom]
Add @types/jsdom
dependency (#11999)[jest-environment-jsdom]
Do not reset the global.document too early on teardown (#11871)[jest-transform]
Improve error and warning messages (#11998)[jest-worker]
Pass execArgv
correctly to worker_threads
worker (#12069)FAQs
A set of utility functions for expect and related packages
The npm package jest-matcher-utils receives a total of 15,804,639 weekly downloads. As such, jest-matcher-utils popularity was classified as popular.
We found that jest-matcher-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.