@cucumber/pretty-formatter

中文文档
4.1.0发布于 2026/09/27MITTypeScriptES Module构建来源已验证近 30 天下载 631.3万


漂亮的东西

为终端提供丰富的Cucumber进展和成果格式

中文使用文档
文档目录5 节
  1. 使用量
  2. 摘要
  3. 进度
  4. 漂亮插件
  5. 主题


漂亮的东西

为终端提供丰富的Cucumber进展和成果格式

Latest version on npm Build status

Example output of the pretty formatting, showing the different colors used

使用量

此软件包用于内部 @cucumber/cucumber 提供 summary, (中文(简体) ), progress 财务报告和审定财务报表 pretty 格式化器;不需要自己安装或管理. 关于用法,见 https://github.com/cucumber/cucumber-js/blob/main/docs/formaters.md 互联网档案馆的存檔,存档日期2011-12-21。 。 。 .

您可以使用这些低级课程来为Cucumber不同的执行提供格式化.

摘要

打印测试结果摘要,包括非通过方案、统计和片段.

import { SummaryPrinter } from '@cucumber/pretty-formatter'

const printer = new SummaryPrinter()

// each time a message is emitted
printer.update(envelope)

也可以用来总结一个已经发生的测试运行, 并预留人口 Query 对象 :

import { Query } from '@cucumber/query'
import { SummaryPrinter } from '@cucumber/pretty-formatter'

const query = new Query()

// each time a message is emitted
query.update(envelope)

// later
SummaryPrinter.summarise(query)

进度

打印测试进度为单字符状态指标.

import { ProgressPrinter } from '@cucumber/pretty-formatter'

const printer = new ProgressPrinter()

// each time a message is emitted
printer.update(envelope)

漂亮插件

打印以预设的Gherkin风格格式测试进度.

import { PrettyPrinter } from '@cucumber/pretty-formatter'

const printer = new PrettyPrinter()

// each time a message is emitted
printer.update(envelope)

主题

这是一个主题的计划:

interface Theme {
    attachment?: Style
    dataTable?: {
        all?: Style
        border?: Style
        content?: Style
    }
    docString?: {
        all?: Style
        content?: Style
        delimiter?: Style
        mediaType?: Style
    }
    feature?: {
        all?: Style
        keyword?: Style
        name?: Style
    }
    location?: Style
    rule?: {
        all?: Style
        keyword?: Style
        name?: Style
    }
    scenario?: {
        all?: Style
        keyword?: Style
        name?: Style
    }
    status?: {
        all?: Partial<Record<TestStepResultStatus, Style>>
        icon?: Partial<Record<TestStepResultStatus, string>>
        progress?: Partial<Record<TestStepResultStatus, string>>
    }
    step?: {
        argument?: Style
        keyword?: Style
        text?: Style
    }
    tag?: Style
    symbol?: {
        bullet?: string
    }
}

enum TestStepResultStatus {
    UNKNOWN = "UNKNOWN",
    PASSED = "PASSED",
    SKIPPED = "SKIPPED",
    PENDING = "PENDING",
    UNDEFINED = "UNDEFINED",
    AMBIGUOUS = "AMBIGUOUS",
    FAILED = "FAILED"
}

Style 是任意 节点.js 支持修改 或数组它们.

见 默认主题 为了一个好的例子。 出口为 CUCUMBER_THEME,所以你可以克隆和扩展它 如果你愿意.

版本与发布记录

@cucumber/pretty-formatter 共发布 21 个版本,首次发布于 2021/01/08;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.1.0latest2026/09/271 个月前
4.0.22026/09/022 个月前
4.0.12026/08/063 个月前
4.0.02026/06/124 个月前
3.3.12026/05/145 个月前
3.3.02026/05/036 个月前

关于 @cucumber/pretty-formatter 的常见问题

@cucumber/pretty-formatter 是什么?

漂亮的东西 为终端提供丰富的Cucumber进展和成果格式

如何安装 @cucumber/pretty-formatter?

在项目目录运行 npm install @cucumber/pretty-formatter,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@cucumber/messages(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cucumber/pretty-formatter 支持 TypeScript 吗?

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

@cucumber/pretty-formatter 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cucumber/pretty-formatter 可以商用吗?

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

@cucumber/pretty-formatter 的下载量有多少?

根据 npm 官方下载统计,@cucumber/pretty-formatter 在 2026/10/11 – 2026/11/09 这 30 天内被下载 6,313,086 次,日均约 210,436 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cucumber/pretty-formatter 还在维护吗?

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