Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Don't leak process variable.

Merrick Christensen831771c5422e
diff --git a/mocha.js b/mocha.js
index 408c3dd4..4f450c4e 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1,6 +1,5 @@
;(function(){
-
// CommonJS require()
function require(p){
@@ -32,11 +31,11 @@ require.register = function (path, fn){
require.relative = function (parent) {
return function(p){
if ('.' != p.charAt(0)) return require(p);
-
+
var path = parent.split('/')
, segs = p.split('/');
path.pop();
-
+
for (var i = 0; i < segs.length; i++) {
var seg = segs[i];
if ('..' == seg) path.pop();
@@ -52,9 +51,9 @@ require.register("browser/debug.js", function(module, exports, require){
module.exports = function(type){
return function(){
-
}
};
+
}); // module: browser/debug.js
require.register("browser/diff.js", function(module, exports, require){
@@ -805,7 +804,6 @@ Hook.prototype.error = function(err){
this._error = err;
};
-
}); // module: hook.js
require.register("interfaces/bdd.js", function(module, exports, require){
@@ -819,7 +817,7 @@ var Suite = require('../suite')
/**
* BDD-style interface:
- *
+ *
* describe('Array', function(){
* describe('#indexOf()', function(){
* it('should return -1 when not present', function(){
@@ -831,7 +829,7 @@ var Suite = require('../suite')
* });
* });
* });
- *
+ *
*/
module.exports = function(suite){
@@ -876,7 +874,7 @@ module.exports = function(suite){
* and callback `fn` containing nested suites
* and/or tests.
*/
-
+
context.describe = context.context = function(title, fn){
var suite = Suite.create(suites[0], title);
suites.unshift(suite);
@@ -956,19 +954,19 @@ var Suite = require('../suite')
/**
* TDD-style interface:
- *
+ *
* exports.Array = {
* '#indexOf()': {
* 'should return -1 when the value is not present': function(){
- *
+ *
* },
*
* 'should return the correct index when the value is present': function(){
- *
+ *
* }
* }
* };
- *
+ *
*/
module.exports = function(suite){
@@ -1006,6 +1004,7 @@ module.exports = function(suite){
}
}
};
+
}); // module: interfaces/exports.js
require.register("interfaces/index.js", function(module, exports, require){
@@ -1028,27 +1027,27 @@ var Suite = require('../suite')
/**
* QUnit-style interface:
- *
+ *
* suite('Array');
- *
+ *
* test('#length', function(){
* var arr = [1,2,3];
* ok(arr.length == 3);
* });
- *
+ *
* test('#indexOf()', function(){
* var arr = [1,2,3];
* ok(arr.indexOf(1) == 0);
* ok(arr.indexOf(2) == 1);
* ok(arr.indexOf(3) == 2);
* });
- *
+ *
* suite('String');
- *
+ *
* test('#length', function(){
* ok('foo'.length == 3);
* });
- *
+ *
*/
module.exports = function(suite){
@@ -1091,7 +1090,7 @@ module.exports = function(suite){
/**
* Describe a "suite" with the given `title`.
*/
-
+
context.suite = function(title){
if (suites.length > 1) suites.shift();
var suite = Suite.create(suites[0], title);
@@ -1129,7 +1128,7 @@ var Suite = require('../suite')
* suiteSetup(function(){
*
* });
- *
+ *
* test('should return -1 when not present', function(){
*
* });
@@ -1710,7 +1709,7 @@ exports.colors = {
/**
* Default symbol map.
*/
-
+
exports.symbols = {
ok: '✓',
err: '✖',
@@ -3080,7 +3079,7 @@ exports = module.exports = Min;
function Min(runner) {
Base.call(this, runner);
-
+
runner.on('start', function(){
// clear screen
process.stdout.write('\u001b[2J');
@@ -3100,6 +3099,7 @@ F.prototype = Base.prototype;
Min.prototype = new F;
Min.prototype.constructor = Min;
+
}); // module: reporters/min.js
require.register("reporters/nyan.js", function(module, exports, require){
@@ -3746,7 +3746,7 @@ function XUnit(runner) {
runner.on('pass', function(test){
tests.push(test);
});
-
+
runner.on('fail', function(test){
tests.push(test);
});
@@ -3763,7 +3763,7 @@ function XUnit(runner) {
}, false));
tests.forEach(test);
- console.log('</testsuite>');
+ console.log('</testsuite>');
});
}
@@ -5006,7 +5006,7 @@ exports.indexOf = function(arr, obj, start){
/**
* Array#reduce (<=IE8)
- *
+ *
* @param {Array} array
* @param {Function} fn
* @param {Object} initial value
@@ -5234,7 +5234,7 @@ exports.highlightTags = function(name) {
* the browser.
*/
-process = {};
+var process = {};
process.exit = function(status){};
process.stdout = {};
global = window;
diff --git a/support/tail.js b/support/tail.js
index 0f9b64a4..500a2e7d 100644
--- a/support/tail.js
+++ b/support/tail.js
@@ -7,7 +7,7 @@
* the browser.
*/
-process = {};
+var process = {};
process.exit = function(status){};
process.stdout = {};
global = window;