Automating test results reporting
It's cool we have automated test execution, and Mocha makes the test results look nice with all those check marks. What if the management wants a graph of test failure trends over time? Or there could be any number of reasons to report test results as data rather than a user-friendly printout on the console.
Mocha uses what's called a Reporter to report test results. A Mocha Reporter is a module that prints data in whatever format it supports. Information is on the Mocha website:Â Â https://mochajs.org/#reporters.
You will find the current list of available reporters
like so:
# mocha --reporters dot - dot matrix doc - html documentation spec - hierarchical spec list json - single json object progress - progress bar list - spec-style listing tap - test-anything-protocol ...
Then you use a specific reporter
like so:
# mocha --reporter tap test 1..4 ok 1 Users Test List user list created users ok 2 Users Test find user find created users...