UNPKG

1.24 kBJavaScriptView Raw
1'use strict';
2
3/**
4 * Module dependencies.
5 */
6
7var Base = require('./base');
8var inherits = require('../utils').inherits;
9var color = Base.color;
10var cursor = Base.cursor;
11
12/**
13 * Expose `List`.
14 */
15
16exports = module.exports = List;
17
18/**
19 * Initialize a new `List` test reporter.
20 *
21 * @api public
22 * @param {Runner} runner
23 */
24function List (runner) {
25 Base.call(this, runner);
26
27 var self = this;
28 var n = 0;
29
30 runner.on('start', function () {
31 console.log();
32 });
33
34 runner.on('test', function (test) {
35 process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
36 });
37
38 runner.on('pending', function (test) {
39 var fmt = color('checkmark', ' -') +
40 color('pending', ' %s');
41 console.log(fmt, test.fullTitle());
42 });
43
44 runner.on('pass', function (test) {
45 var fmt = color('checkmark', ' ' + Base.symbols.ok) +
46 color('pass', ' %s: ') +
47 color(test.speed, '%dms');
48 cursor.CR();
49 console.log(fmt, test.fullTitle(), test.duration);
50 });
51
52 runner.on('fail', function (test) {
53 cursor.CR();
54 console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
55 });
56
57 runner.on('end', self.epilogue.bind(self));
58}
59
60/**
61 * Inherit from `Base.prototype`.
62 */
63inherits(List, Base);