Your mileage may vary, but I came up with the following single-line snapshot and it served me well:
if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);
In addition, if you want it to be displayed in the asyncjs format that Cloud9 expects, you need to provide a special reporter. Here is a really simple example of what a simple reporter looks like:
if (!module.parent){ (new(require("mocha"))()).ui("exports").reporter(function(r){ var i = 1, n = r.grepTotal(r.suite); r.on("fail", function(t){ console.log("\x1b[31m[%d/%d] %s FAIL\x1b[0m", i++, n, t.fullTitle()); }); r.on("pass", function(t){ console.log("\x1b[32m[%d/%d] %s OK\x1b[0m", i++, n, t.fullTitle()); }); r.on("pending", function(t){ console.log("\x1b[33m[%d/%d] %s SKIP\x1b[0m", i++, n, t.fullTitle()); }); }).addFile(__filename).run(process.exit); }
Kylepdavis
source share