summaryrefslogtreecommitdiff
path: root/node_modules/mocha/lib/reporters/teamcity.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/mocha/lib/reporters/teamcity.js')
-rw-r--r--node_modules/mocha/lib/reporters/teamcity.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/node_modules/mocha/lib/reporters/teamcity.js b/node_modules/mocha/lib/reporters/teamcity.js
new file mode 100644
index 0000000..cef71c8
--- /dev/null
+++ b/node_modules/mocha/lib/reporters/teamcity.js
@@ -0,0 +1,56 @@
+
+/**
+ * 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, "|'");
+} \ No newline at end of file