@voxpelli/node-test-pretty-reporter
v1.1.2
Published
Reporter for node:test that supports colorful diffs etc
Downloads
425
Readme
@voxpelli/node-test-pretty-reporter
Reporter for node:test that supports colorful diffs etc
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:
node:assert
chai
(note:chai.should()
breaks error presentation since18.17.0
, see: voxpelli/node-test-pretty-reporter#6, nodejs/node#48918, chaijs/chai#1530)
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
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.
MoLow/reporters
– many custom reporters fornode:test
nearform/node-test-github-reporter
– another custom report fornode:test
, this one from @nearform and geared towards GitHub Actions
See also
node:test
– the full documentation for thenode:test
module that shipped in Node.js 18nodejs/node-core-test
– a userland port ofnode: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 fornode:test
andnode:assert