Skip to content

armgit / mocha

Public Imported from GitHub
0

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

docs

TJ Holowaychuk1f4429353b24
diff --git a/support/tail.js b/support/tail.js
index 8866b0ca..c8912672 100644
--- a/support/tail.js
+++ b/support/tail.js
@@ -13,6 +13,10 @@ process.exit = function(status){};
process.stdout = {};
global = window;
+/**
+ * next tick implementation.
+ */
+
process.nextTick = (function(){
// postMessage behaves badly on IE8
if (window.ActiveXObject || !window.postMessage) {
@@ -36,18 +40,30 @@ process.nextTick = (function(){
}
})();
+/**
+ * Remove uncaughtException listener.
+ */
+
process.removeListener = function(e){
if ('uncaughtException' == e) {
window.onerror = null;
}
};
+/**
+ * Implements uncaughtException listener.
+ */
+
process.on = function(e, fn){
if ('uncaughtException' == e) {
window.onerror = fn;
}
};
+/**
+ * Expose mocha.
+ */
+
window.mocha = require('mocha');
// boot
@@ -56,6 +72,10 @@ window.mocha = require('mocha');
, utils = mocha.utils
, Reporter = mocha.reporters.HTML
+ /**
+ * Highlight the given string of `js`.
+ */
+
function highlight(js) {
return js
.replace(/</g, '&lt;')
@@ -68,6 +88,10 @@ window.mocha = require('mocha');
.replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>')
}
+ /**
+ * Parse the given `qs`.
+ */
+
function parse(qs) {
return utils.reduce(qs.replace('?', '').split('&'), function(obj, pair){
var i = pair.indexOf('=')
@@ -79,6 +103,10 @@ window.mocha = require('mocha');
}, {});
}
+ /**
+ * Setup mocha with the give `ui` name.
+ */
+
mocha.setup = function(ui){
ui = mocha.interfaces[ui];
if (!ui) throw new Error('invalid mocha interface "' + ui + '"');
@@ -86,6 +114,10 @@ window.mocha = require('mocha');
suite.emit('pre-require', window);
};
+ /**
+ * Run mocha, returning the Runner.
+ */
+
mocha.run = function(){
suite.emit('run');
var runner = new mocha.Runner(suite);