jest-matcher-utils

中文文档
30.5.2发布于 2026/09/18MITTypeScriptESM + CJS近 30 天下载 3.2亿

A set of utility functions for expect and related packages

原始使用文档
文档目录5 节
  1. Installation
  2. Exports ( src/index.ts )
  3. Functions
  4. Types
  5. Constants

jest-matcher-utils

This package's exports are most notably used by expect's this.utils.

Installation

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

Exports (src/index.ts)

Functions

stringify highlightTrailingWhitespace printReceived printExpected printWithType ensureNoExpected ensureActualIsNumber ensureExpectedIsNumber ensureNumbers ensureExpectedIsNonNegativeInteger printDiffOrStringify diff pluralize getLabelPrinter matcherErrorMessage matcherHint

Types

MatcherHintOptions DiffOptions

Constants

EXPECTED_COLOR RECEIVED_COLOR INVERTED_COLOR BOLD_WEIGHT DIM_COLOR SUGGEST_TO_CONTAIN_EQUAL SERIALIZABLE_PROPERTIES

版本与发布记录

jest-matcher-utils 共发布 257 个版本,首次发布于 2016/07/12;过去 12 个月发布了 6 个版本。

版本发布日期距今
30.5.2latest2026/09/181 个月前
30.5.12026/09/012 个月前
30.5.02026/08/282 个月前
30.4.12026/05/086 个月前
30.4.02026/05/086 个月前
30.3.02026/03/107 个月前

其他发布通道:next → 30.0.0-rc.1。

关于 jest-matcher-utils 的常见问题

jest-matcher-utils 是什么?

A set of utility functions for expect and related packages

如何安装 jest-matcher-utils?

在项目目录运行 npm install jest-matcher-utils,或使用 pnpm add / yarn add / bun add。

jest-matcher-utils 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

jest-matcher-utils 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

jest-matcher-utils 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

jest-matcher-utils 可以商用吗?

jest-matcher-utils 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

jest-matcher-utils 的下载量有多少?

根据 npm 官方下载统计,jest-matcher-utils 在 2026/10/07 – 2026/11/05 这 30 天内被下载 324,085,075 次,日均约 10,802,836 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

jest-matcher-utils 还在维护吗?

最新版本 30.5.2 发布于 2026/09/18(1 个月前);至今共发布 257 个版本,其中过去 12 个月发布了 6 个;首次发布于 2016/07/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。