summaryrefslogtreecommitdiff
path: root/node_modules/mocha/lib/reporters/tap.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/mocha/lib/reporters/tap.js')
-rw-r--r--node_modules/mocha/lib/reporters/tap.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/node_modules/mocha/lib/reporters/tap.js b/node_modules/mocha/lib/reporters/tap.js
new file mode 100644
index 0000000..e601dc9
--- /dev/null
+++ b/node_modules/mocha/lib/reporters/tap.js
@@ -0,0 +1,63 @@
+
+/**
+ * Module dependencies.
+ */
+
+var Base = require('./base')
+ , cursor = Base.cursor
+ , color = Base.color;
+
+/**
+ * Expose `TAP`.
+ */
+
+exports = module.exports = TAP;
+
+/**
+ * Initialize a new `TAP` reporter.
+ *
+ * @param {Runner} runner
+ * @api public
+ */
+
+function TAP(runner) {
+ Base.call(this, runner);
+
+ var self = this
+ , stats = this.stats
+ , total = runner.total
+ , n = 1;
+
+ runner.on('start', function(){
+ console.log('%d..%d', 1, total);
+ });
+
+ runner.on('test end', function(){
+ ++n;
+ });
+
+ runner.on('pending', function(test){
+ console.log('ok %d %s # SKIP -', n, title(test));
+ });
+
+ runner.on('pass', function(test){
+ console.log('ok %d %s', n, title(test));
+ });
+
+ runner.on('fail', function(test, err){
+ console.log('not ok %d %s', n, title(test));
+ console.log(err.stack.replace(/^/gm, ' '));
+ });
+}
+
+/**
+ * Return a TAP-safe title of `test`
+ *
+ * @param {Object} test
+ * @return {String}
+ * @api private
+ */
+
+function title(test) {
+ return test.fullTitle().replace(/#/g, '');
+}