Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to show only the summary of a Mocha test suite in the cli report?

Tags:

I run my Mocha tests using the following command:

mocha --compilers js:babel-core/register --recursive --colors --watch

The tests work perfectly, but I am not satisfied with the look of the report in the terminal. For a TDD approach I want to write a lot of tests beforehand that all fail, then make start to write the code that makes them pass.

Right now I get the summary of test results on top, then details for every failed test. I want to see the summary at the end, so I don't have to scroll through the terminal every time I check.

How can I move the summary to the bottom? Can I make a separate test command that ONLY shows the summary?

Thanks for any help

like image 457
Mauro Bringolf Avatar asked Nov 19 '16 13:11

Mauro Bringolf


1 Answers

What you are seeing is the default reporter spec:

Spec reporter screenshot

This is the default reporter. The “spec” reporter outputs a hierarchical view nested just as the test cases are.

If you have lots of tests the output from the spec reporter can easily fill several pages in your console. What you probably want is a more compact test reporter, like dot-matrix

Dot matrix reporter screenshot

The dot matrix (or “dot”) reporter is simply a series of characters which represent test cases. Failures highlight in red exclamation marks (!), pending tests with a blue comma (,), and slow tests as yellow. Good if you prefer minimal output.

You can call the dot matrix reporter with mocha -R dot

like image 177
BillyTom Avatar answered Sep 22 '22 16:09

BillyTom