1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | var Base = require('./base');
|
8 | var JSON = require('json3');
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | exports = module.exports = List;
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function List (runner) {
|
23 | Base.call(this, runner);
|
24 |
|
25 | var self = this;
|
26 | var total = runner.total;
|
27 |
|
28 | runner.on('start', function () {
|
29 | console.log(JSON.stringify(['start', { total: total }]));
|
30 | });
|
31 |
|
32 | runner.on('pass', function (test) {
|
33 | console.log(JSON.stringify(['pass', clean(test)]));
|
34 | });
|
35 |
|
36 | runner.on('fail', function (test, err) {
|
37 | test = clean(test);
|
38 | test.err = err.message;
|
39 | test.stack = err.stack || null;
|
40 | console.log(JSON.stringify(['fail', test]));
|
41 | });
|
42 |
|
43 | runner.on('end', function () {
|
44 | process.stdout.write(JSON.stringify(['end', self.stats]));
|
45 | });
|
46 | }
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | function clean (test) {
|
57 | return {
|
58 | title: test.title,
|
59 | fullTitle: test.fullTitle(),
|
60 | duration: test.duration,
|
61 | currentRetry: test.currentRetry()
|
62 | };
|
63 | }
|