/
reporters.spec.js
40 lines (36 loc) · 1.04 KB
/
reporters.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
var helpers = require('../helpers');
var invokeMocha = helpers.invokeMocha;
var escapeRegExp = helpers.escapeRegExp;
var reporters = require('../../../lib/mocha').reporters;
describe('--reporters', function() {
it('should dump a list of all reporters with descriptions', function(done) {
var expected = Object.keys(reporters)
.filter(function(name) {
return (
/^[a-z]/.test(name) &&
!(reporters[name].abstract || reporters[name].browserOnly)
);
})
.map(function(name) {
return {
name: escapeRegExp(name),
description: escapeRegExp(reporters[name].description)
};
});
invokeMocha(['--reporters'], function(err, result) {
if (err) {
return done(err);
}
expect(result.code, 'to be', 0);
expected.forEach(function(reporter) {
expect(
result.output,
'to match',
new RegExp(reporter.name + '\\s*-\\s*' + reporter.description)
);
});
done();
});
});
});