felixge/node-utest — pull request #3 by mantoni (2013-04-28 08:34:53+00:00)
Title: ConsoleReporter

# Why a ConsoleReporter?

I wanted to run utest in the browser (through Browserify). Works fine, except the BashReporter prints to `process.stdout` and the `exit` event from `process` is used.

- Platform independent ConsoleReporter
- Collection now emits `completed` with the stats when done
- The `completed` event is handled in `index.js` rather than in the BashReporter to have it in a single place
- Collection now emits `run` before running a test case

Let me know if you'd like some other way of injecting the reporter. The way urun is doing it might not work well for utest since you would have to provide a reporter for each test. I'm happy to change it though.

# Shameless plug

You can see what it looks like here: https://github.com/mantoni/consolify

I also created [Phantomic](https://github.com/mantoni/phantomic) which allows you to pipe any JavaScript to Phantom.JS and the console output from the browser back.

I'm using my forked utest in another project to verify it's all working fine. Have a look at the
[Makefile](https://github.com/mantoni/listen.js/blob/master/Makefile).

# The commit message

To be able to run test cases in a browsers via Browserify, a more
platform independant reporter is needed. The BashReporter is also
listening on process 'exit' events and calls 'process.reallyExit' on
failure. The code unrelated to reporting functionality was moved into
'index.js'.

- Allow to configure a reporter by setting test.Reporter to a reporter
constructor
- Added ConsoleReporter that logs to console.log, console.info,
console.warn and console.error
- Emitting 'run' and 'completed' events in collections
- Removed 'process.reallyExit call' from BashReporter and instead
calling 'process.exit' with the approriate exit code when the
collection emits the 'completed' event