1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | var Base = require('./base');
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | exports = module.exports = TAP;
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | function TAP (runner) {
|
22 | Base.call(this, runner);
|
23 |
|
24 | var n = 1;
|
25 | var passes = 0;
|
26 | var failures = 0;
|
27 |
|
28 | runner.on('start', function () {
|
29 | var total = runner.grepTotal(runner.suite);
|
30 | console.log('%d..%d', 1, total);
|
31 | });
|
32 |
|
33 | runner.on('test end', function () {
|
34 | ++n;
|
35 | });
|
36 |
|
37 | runner.on('pending', function (test) {
|
38 | console.log('ok %d %s # SKIP -', n, title(test));
|
39 | });
|
40 |
|
41 | runner.on('pass', function (test) {
|
42 | passes++;
|
43 | console.log('ok %d %s', n, title(test));
|
44 | });
|
45 |
|
46 | runner.on('fail', function (test, err) {
|
47 | failures++;
|
48 | console.log('not ok %d %s', n, title(test));
|
49 | if (err.stack) {
|
50 | console.log(err.stack.replace(/^/gm, ' '));
|
51 | }
|
52 | });
|
53 |
|
54 | runner.on('end', function () {
|
55 | console.log('# tests ' + (passes + failures));
|
56 | console.log('# pass ' + passes);
|
57 | console.log('# fail ' + failures);
|
58 | });
|
59 | }
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | function title (test) {
|
69 | return test.fullTitle().replace(/#/g, '');
|
70 | }
|