@voxpelli/node-test-pretty-reporter
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

@voxpelli/node-test-pretty-reporter

Reporter for node:test that supports colorful diffs etc

npm version npm downloads js-semistandard-style Module type: ESM Types in JS Follow @voxpelli@mastodon.social

Usage

npm install -D @voxpelli/node-test-pretty-reporter
node --test --test-reporter=@voxpelli/node-test-pretty-reporter

Why another test reporter?

This one is similar to the built-in spec reporter but differs in some ways which I personally prefer.

Rendering diffs from assertions

Outputs colored diffs when a test is failed with an Error that has expected and actual properties (respecting a showDiff property set to false).

Diff is generated by jest-diff (no other part of jest is used in this reporter).

Assertion libraries that outputs compatible errors:

As with other changes, this makes the reporter on par with Mocha.

Output styling

The output styling aligns more with Mocha's spec reporter:

  • Errors are presented at the end instead of in the list of tests (also done in built in since nodejs/node#47164)
  • Less visually intense, eg. no in front of names and only failed tests gets colored
  • Durations are only reported if considered slow (using same default as Mocha: 75ms)
  • No redundant mentioning of a test suite after the suite has completed – opts for a clean tree from top to bottom instead

Outputting the full cause chain of an Error

When used with at least Node 18.17.0 or 20.2.0 this is supported (see issue #2).

Since those same versions the cause chain is also printed in the built in spec reporter, but done through util.inspect() there rather than the custom output here.

Example output

CLI output

Similar modules

I have not tested any of these myself yet so can't say if they work well or not, but adding here for reference.

See also

  • node:test – the full documentation for the node:test module that shipped in Node.js 18
  • nodejs/node-core-test – a userland port of node:test making it available in Node.js 14 and later (this reporter has not been tested with this userland port)
  • @matteo.collina/tspl – test planner for node:test and node:assert

Readme

Keywords

Package Sidebar

Install

npm i @voxpelli/node-test-pretty-reporter

Weekly Downloads

23

Version

1.1.1

License

MIT

Unpacked Size

19.5 kB

Total Files

18

Last publish

Collaborators

  • voxpelli