forked from glenjamin/mocha-multi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.js
66 lines (59 loc) · 1.97 KB
/
verify.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var Mocha = require('mocha'),
should=require('should'),
fs=require('fs'),
debug = require('debug')('mocha:verify:multi'),
async = require('async'),
chalk = require('chalk');
var reporters = [
"dot", "doc", "spec", "json", "progress",
"list", "tap", "landing", "xunit", "min",
"json-stream", "markdown", "nyan"
], now = new Date();
var reportersWithOptions = []
.concat(reporters.map(function (reporter) {
var outFilename = tempName(reporter + '-stdout');
var options = {};
options[reporter] = {
stdout: outFilename
};
return {
testName: reporter + ' (with options.stdout)',
outFilename: outFilename,
options: options
};
}))
.concat(reporters.map(function (reporter) {
var outFilename = tempName(reporter + '-str');
var options = {};
options[reporter] = outFilename;
return {
testName: reporter + ' (with options as string)',
outFilename: outFilename,
options: options
};
}));
should(process.env.multi).not.be.ok;
function tempName(reporter) {
return "/tmp/mocha-multi." + reporter + "." + (+now);
}
process.setMaxListeners(reportersWithOptions.length);
async.eachSeries(reportersWithOptions, function(reporter, next) {
debug("reporter %s", reporter.testName);
debug("reporterOptions %j", reporter.options);
var mocha = new Mocha({
ui: 'bdd',
reporter: "mocha-multi",
reporterOptions: reporter.options
});
mocha.addFile("test/dummy-spec.js");
mocha.run(function onRun(failures){
debug("done running %j", reporter.testName);
process.nextTick(next);
});
}, function(err, results) {
reportersWithOptions.forEach(function(reporter) {
fs.statSync.bind(fs, reporter.outFilename).should.not.throw();
fs.unlinkSync(reporter.outFilename);
console.log(chalk.green("%s OK"), reporter.testName);
});
});