Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Add `say` notification support

Maciej Małecki3a0676feb887
diff --git a/bin/_mocha b/bin/_mocha
index 2f34a652..c781dd86 100755
--- a/bin/_mocha
+++ b/bin/_mocha
@@ -47,6 +47,7 @@ program
.option('-C, --no-colors', 'force disabling of colors')
.option('-c, --colors', 'force enabling of colors')
.option('-G, --growl', 'enable growl notification support')
+ .option('-S, --say [voice]', 'enable say notification support')
.option('-d, --debug', "enable node's debugger")
.option('--globals <names>', 'allow the given comma-delimited global [names]', list, [])
.option('--ignore-leaks', 'ignore global variable leaks')
@@ -237,6 +238,7 @@ function run(suite, fn) {
if (program.ignoreLeaks) runner.ignoreLeaks = true;
if (program.grep) runner.grep(new RegExp(program.grep));
if (program.growl) growl(runner, reporter);
+ if (program.say) say(runner, reporter);
runner.run(fn);
}
@@ -259,6 +261,22 @@ function growl(runner, reporter) {
});
}
+function say(runner, reporter) {
+ var say = require('say');
+
+ runner.on('end', function(){
+ var stats = reporter.stats
+ , msg;
+
+ if (stats.failures) {
+ msg = stats.failures + ' of ' + runner.total + ' tests failed';
+ } else {
+ msg = stats.passes + ' tests passed in ' + stats.duration + 'ms';
+ }
+ say.speak('string' == typeof program.say ? program.say : 'Alex', msg);
+ });
+}
+
/**
* Parse list.
*/
diff --git a/package.json b/package.json
index cb43975a..4e3930ed 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
"commander": "0.3.2"
, "growl": "1.4.x"
, "debug": "*"
+ , "say": "0.5.x"
}
, "devDependencies": {
"should": "0.3.x"