Skip to content

Instantly share code, notes, and snippets.

@itaifrenkel
Last active August 29, 2015 14:17
Show Gist options
  • Save itaifrenkel/4c08483903a4792f27c9 to your computer and use it in GitHub Desktop.
Save itaifrenkel/4c08483903a4792f27c9 to your computer and use it in GitHub Desktop.
Integrating mocha tests with riemann
var failedTests = [];
new Mocha()
.ui("bdd")
.reporter("tap")
.addFile(__dirname + '/' + testSuiteName + '.js')
.run()
.on('fail', function (test, err) {
failedTests.push(test);
})
.on('end', function () {
var event = riemann.Event({
host: hostBeingTested,
service: testSuiteName + " test suite",
state: failedTests.length == 0 ? "passed" : "failed",
tags: ["test"]
description: failedTests.map(function(test) {
return test.fullTitle() + "\n" + test.err.stack;
}).join('\n'),
});
riemann.send(event, client.tcp);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment