Skip to content

armgit / mocha

Public Imported from GitHub
0

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

fixed / refactored teamcity reporter

TJ Holowaychuk64cc14763530
diff --git a/lib/reporters/teamcity.js b/lib/reporters/teamcity.js
index 04a9ce84..fa4d750d 100644
--- a/lib/reporters/teamcity.js
+++ b/lib/reporters/teamcity.js
@@ -1,16 +1,25 @@
-exports = module.exports = Teamcity;
-function Teamcity(runner, options) {
+/**
+ * Module dependencies.
+ */
+
+var Base = require('./base');
+
+/**
+ * Expose `Teamcity`.
+ */
+
+exports = module.exports = Teamcity;
- var start_time;
+function Teamcity(runner) {
+ Base.call(this, runner);
+ var stats = this.stats;
runner.on('start', function() {
- start_time = new Date().getTime();
console.log("##teamcity[testSuiteStarted name='mocha.suite']");
});
runner.on('test', function(test) {
- test.start = new Date().getTime();
console.log("##teamcity[testStarted name='" + test.fullTitle() + "']");
});
@@ -19,16 +28,14 @@ function Teamcity(runner, options) {
});
runner.on('pending', function(test) {
- console.log("##teamcity[testIgnored name='" + test.fullTitle() + "' message='" + err.message + "']");
+ console.log("##teamcity[testIgnored name='" + test.fullTitle() + "' message='pending']");
});
runner.on('test end', function(test) {
- var duration = new Date().getTime() - test.start;
- console.log("##teamcity[testFinished name='" + test.fullTitle() + "' duration='" + duration + "']");
+ console.log("##teamcity[testFinished name='" + test.fullTitle() + "' duration='" + test.duration + "']");
});
runner.on('end', function() {
- var duration = new Date().getTime() - start_time;
- console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='" + duration + "']");
+ console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='" + stats.duration + "']");
});
}