UNPKG

1.34 kBJavaScriptView Raw
1var Mocha = require('mocha'),
2 should=require('should'),
3 fs=require('fs'),
4 debug = require('debug')('mocha:verify:multi'),
5 async = require('async'),
6 chalk = require('chalk');
7
8var reporters = [
9 "dot", "doc", "spec", "json", "progress",
10 "list", "tap", "landing", "xunit", "min",
11 "json-stream", "markdown", "nyan"
12], deferreds = [], now = new Date();
13
14should(process.env.multi).not.be.ok;
15
16function tempName(reporter) {
17 return "/tmp/mocha-multi." + reporter + "." + (+now);
18}
19
20process.setMaxListeners(reporters.length);
21
22async.eachSeries(reporters, function(reporter, next) {
23 var reporterOptions = {};
24 debug("reporter %s", reporter);
25 reporterOptions[reporter] = {
26 stdout: tempName(reporter)
27 };
28 debug("reporterOptions %j", reporterOptions);
29 var mocha = new Mocha({
30 ui: 'bdd',
31 reporter: "mocha-multi",
32 reporterOptions: reporterOptions
33 });
34 mocha.addFile("test/dummy-spec.js");
35 mocha.run(function onRun(failures){
36 debug("done running %j", reporter);
37 process.nextTick(next);
38 });
39}, function(err, results) {
40 reporters.forEach(function(reporter) {
41 fs.statSync.bind(fs, tempName(reporter)).should.not.throw();
42 fs.unlinkSync(tempName(reporter));
43 console.log(chalk.green("%s OK"), reporter);
44 });
45});