1
0
Fork 0
mirror of https://github.com/seejohnrun/haste-server.git synced 2024-11-01 11:31:22 +00:00
haste-server/node_modules/mocha/lib/reporters/teamcity.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

2012-02-06 19:09:01 +00:00
/**
* Module dependencies.
*/
var Base = require('./base');
/**
* Expose `Teamcity`.
*/
exports = module.exports = Teamcity;
/**
* Initialize a new `Teamcity` reporter.
*
* @param {Runner} runner
* @api public
*/
function Teamcity(runner) {
Base.call(this, runner);
var stats = this.stats;
runner.on('start', function() {
console.log("##teamcity[testSuiteStarted name='mocha.suite']");
});
runner.on('test', function(test) {
console.log("##teamcity[testStarted name='%s']", escape(test.fullTitle()));
});
runner.on('fail', function(test, err) {
console.log("##teamcity[testFailed name='%s' message='%s']", escape(test.fullTitle()), escape(err.message));
});
runner.on('pending', function(test) {
console.log("##teamcity[testIgnored name='%s' message='pending']", escape(test.fullTitle()));
});
runner.on('test end', function(test) {
console.log("##teamcity[testFinished name='%s' duration='%s']", escape(test.fullTitle()), test.duration);
});
runner.on('end', function() {
console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='%s']", stats.duration);
});
}
/**
* Escape the given `str`.
*/
function escape(str) {
return str.replace(/'/g, "|'");
}