Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
jest-matcher-utils
Advanced tools
A set of utility functions for jest-matchers and related packages
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.
FAQs
A set of utility functions for expect and related packages
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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.