测试报告器
¥Test reporters
node:test 模块支持传递 --test-reporter 标志,以便测试运行器使用特定的报告程序。
¥The node:test module supports passing --test-reporter
flags for the test runner to use a specific reporter.
支持以下内置报告器:
¥The following built-reporters are supported:
-
taptap报告器以 TAP 格式输出测试结果。¥
tapThetapreporter outputs the test results in the TAP format. -
specspec报告器以人类可读的格式输出测试结果。¥
specThespecreporter outputs the test results in a human-readable format. -
dotdot报告器以紧凑格式输出测试结果,其中每个通过的测试用.表示,每个失败的测试用X表示。¥
dotThedotreporter outputs the test results in a compact format, where each passing test is represented by a., and each failing test is represented by aX. -
junitjunit 报告器以 jUnit XML 格式输出测试结果¥
junitThe junit reporter outputs test results in a jUnit XML format
当 stdout 为 TTY 时,默认使用 spec 报告器。否则,默认使用 tap 报告器。
¥When stdout is a TTY, the spec reporter is used by default.
Otherwise, the tap reporter is used by default.
报告器可通过 node:test/reporters 模块获得:
¥The reporters are available via the node:test/reporters module:
import { tap, spec, dot, junit } from 'node:test/reporters';const { tap, spec, dot, junit } = require('node:test/reporters');