Socket
Socket
Sign inDemoInstall

mocha

Package Overview
Dependencies
Maintainers
1
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

139

_mocha.js

@@ -32,3 +32,3 @@

return function(p){
if ('.' != p[0]) return require(p);
if ('.' != p.charAt(0)) return require(p);

@@ -690,4 +690,5 @@ var path = parent.split('/')

exports.version = '0.5.0';
exports.version = '0.7.0';
exports.utils = require('./utils');
exports.interfaces = require('./interfaces');

@@ -701,2 +702,3 @@ exports.reporters = require('./reporters');

exports.watch = require('./watch');
}); // module: mocha.js

@@ -1121,8 +1123,15 @@

, canvas = stat.find('canvas').get(0)
, ctx = canvas.getContext('2d')
, progress = new Progress;
, ctx, progress
if (canvas.getContext) {
ctx = canvas.getContext('2d');
progress = new Progress;
}
if (!root.length) return error('#mocha div missing, add it to your document');
progress.size(50);
if (progress) {
progress.size(50);
}
runner.on('suite', function(suite){

@@ -1153,4 +1162,6 @@ if (suite.root) return;

// update progress bar
progress.update(percent).draw(ctx);
if (progress) {
// update progress bar
progress.update(percent).draw(ctx);
}

@@ -1171,2 +1182,9 @@ // update stats

var str = test.err.stack || test.err;
// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
// check for the result of the stringifying.
if ('[object Error]' == str) {
str = test.err.message;
}
var err = $('<pre class="error">' + str + '</pre>');

@@ -1217,2 +1235,3 @@ el.append(err);

}
}); // module: reporters/html.js

@@ -2001,2 +2020,3 @@

, Test = require('./test')
, utils = require('./utils')
, noop = function(){};

@@ -2038,3 +2058,3 @@

this.grep(/.*/);
this.globals(Object.keys(global).concat(['errno']));
this.globals(utils.keys(global).concat(['errno']));
}

@@ -2074,3 +2094,3 @@

debug('globals %j', arr);
arr.forEach(function(arr){
utils.forEach(arr, function(arr){
this._globals.push(arr);

@@ -2090,4 +2110,4 @@ }, this);

var leaks = Object.keys(global).filter(function(key){
return !~this._globals.indexOf(key);
var leaks = utils.filter(utils.keys(global), function(key){
return !~utils.indexOf(this._globals, key);
}, this);

@@ -2423,2 +2443,3 @@

, debug = require('browser/debug')('suite')
, utils = require('./utils')
, Hook = require('./hook');

@@ -2634,3 +2655,3 @@

Suite.prototype.total = function(){
return this.suites.reduce(function(sum, suite){
return utils.reduce(this.suites, function(sum, suite){
return sum + suite.total();

@@ -2697,2 +2718,96 @@ }, 0) + this.tests.length;

};
/**
* Array#forEach (<=IE8)
*
* @param {Array} array
* @param {Function} fn
* @param {Object} scope
* @api private
*/
exports.forEach = function(arr, fn, scope) {
for (var i = 0, l = arr.length; i < l; i++)
fn.call(scope, arr[i], i);
};
/**
* Array#indexOf (<=IE8)
*
* @parma {Array} arr
* @param {Object} obj to find index of
* @param {Number} start
* @api private
*/
exports.indexOf = function (arr, obj, start) {
for (var i = start || 0, l = arr.length; i < l; i++) {
if (arr[i] === obj)
return i;
}
return -1;
};
/**
* Array#reduce (<=IE8)
*
* @param {Array} array
* @param {Function} fn
* @param {Object} initial value
* @param {Object} scope
* @api private
*/
exports.reduce = function(arr, fn, val, scope) {
var rval = val;
for (var i = 0, l = arr.length; i < l; i++) {
rval = fn.call(scope, rval, arr[i], i, arr);
}
return rval;
};
/**
* Array#filter (<=IE8)
*
* @param {Array} array
* @param {Function} fn
* @param {Object} scope
* @api private
*/
exports.filter = function(arr, fn, scope) {
var ret = [];
for (var i = 0, l = arr.length; i < l; i++) {
var val = arr[i];
if (fn.call(scope, val, i, arr))
ret.push(val);
}
return ret;
};
/**
* Object.keys (<=IE8)
*
* @param {Object} obj
* @return {Array} keys
* @api private
*/
exports.keys = Object.keys || function(obj) {
var keys = []
, has = Object.prototype.hasOwnProperty // for `window` on <=IE8
for (var i in obj) {
if (has.call(obj, i)) {
keys.push(i);
}
}
return keys;
};
}); // module: utils.js

@@ -2699,0 +2814,0 @@

0.7.0 / 2011-12-18
==================
* Added support for IE{7,8} [guille]
* Changed: better browser nextTick implementation [guille]
0.6.0 / 2011-12-18

@@ -3,0 +9,0 @@ ==================

5

lib/mocha.js

@@ -12,4 +12,5 @@

exports.version = '0.6.0';
exports.version = '0.7.0';
exports.utils = require('./utils');
exports.interfaces = require('./interfaces');

@@ -22,2 +23,2 @@ exports.reporters = require('./reporters');

exports.Test = require('./test');
exports.watch = require('./watch');
exports.watch = require('./watch');

@@ -46,8 +46,15 @@

, canvas = stat.find('canvas').get(0)
, ctx = canvas.getContext('2d')
, progress = new Progress;
, ctx, progress
if (canvas.getContext) {
ctx = canvas.getContext('2d');
progress = new Progress;
}
if (!root.length) return error('#mocha div missing, add it to your document');
progress.size(50);
if (progress) {
progress.size(50);
}
runner.on('suite', function(suite){

@@ -78,4 +85,6 @@ if (suite.root) return;

// update progress bar
progress.update(percent).draw(ctx);
if (progress) {
// update progress bar
progress.update(percent).draw(ctx);
}

@@ -96,2 +105,9 @@ // update stats

var str = test.err.stack || test.err;
// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
// check for the result of the stringifying.
if ('[object Error]' == str) {
str = test.err.message;
}
var err = $('<pre class="error">' + str + '</pre>');

@@ -141,2 +157,2 @@ el.append(err);

return str;
}
}

@@ -9,2 +9,3 @@

, Test = require('./test')
, utils = require('./utils')
, noop = function(){};

@@ -46,3 +47,3 @@

this.grep(/.*/);
this.globals(Object.keys(global).concat(['errno']));
this.globals(utils.keys(global).concat(['errno']));
}

@@ -80,3 +81,3 @@

debug('globals %j', arr);
arr.forEach(function(arr){
utils.forEach(arr, function(arr){
this._globals.push(arr);

@@ -96,4 +97,4 @@ }, this);

var leaks = Object.keys(global).filter(function(key){
return !~this._globals.indexOf(key);
var leaks = utils.filter(utils.keys(global), function(key){
return !~utils.indexOf(this._globals, key);
}, this);

@@ -100,0 +101,0 @@

@@ -8,2 +8,3 @@

, debug = require('debug')('suite')
, utils = require('./utils')
, Hook = require('./hook');

@@ -217,5 +218,5 @@

Suite.prototype.total = function(){
return this.suites.reduce(function(sum, suite){
return utils.reduce(this.suites, function(sum, suite){
return sum + suite.total();
}, 0) + this.tests.length;
};

@@ -16,2 +16,95 @@

.replace(/>/g, '&gt;');
};
};
/**
* Array#forEach (<=IE8)
*
* @param {Array} array
* @param {Function} fn
* @param {Object} scope
* @api private
*/
exports.forEach = function(arr, fn, scope) {
for (var i = 0, l = arr.length; i < l; i++)
fn.call(scope, arr[i], i);
};
/**
* Array#indexOf (<=IE8)
*
* @parma {Array} arr
* @param {Object} obj to find index of
* @param {Number} start
* @api private
*/
exports.indexOf = function (arr, obj, start) {
for (var i = start || 0, l = arr.length; i < l; i++) {
if (arr[i] === obj)
return i;
}
return -1;
};
/**
* Array#reduce (<=IE8)
*
* @param {Array} array
* @param {Function} fn
* @param {Object} initial value
* @param {Object} scope
* @api private
*/
exports.reduce = function(arr, fn, val, scope) {
var rval = val;
for (var i = 0, l = arr.length; i < l; i++) {
rval = fn.call(scope, rval, arr[i], i, arr);
}
return rval;
};
/**
* Array#filter (<=IE8)
*
* @param {Array} array
* @param {Function} fn
* @param {Object} scope
* @api private
*/
exports.filter = function(arr, fn, scope) {
var ret = [];
for (var i = 0, l = arr.length; i < l; i++) {
var val = arr[i];
if (fn.call(scope, val, i, arr))
ret.push(val);
}
return ret;
};
/**
* Object.keys (<=IE8)
*
* @param {Object} obj
* @return {Array} keys
* @api private
*/
exports.keys = Object.keys || function(obj) {
var keys = []
, has = Object.prototype.hasOwnProperty // for `window` on <=IE8
for (var i in obj) {
if (has.call(obj, i)) {
keys.push(i);
}
}
return keys;
};

@@ -34,3 +34,3 @@ ;(function(){

return function(p){
if ('.' != p[0]) return require(p);
if ('.' != p.charAt(0)) return require(p);

@@ -692,4 +692,5 @@ var path = parent.split('/')

exports.version = '0.5.0';
exports.version = '0.7.0';
exports.utils = require('./utils');
exports.interfaces = require('./interfaces');

@@ -703,2 +704,3 @@ exports.reporters = require('./reporters');

exports.watch = require('./watch');
}); // module: mocha.js

@@ -1123,8 +1125,15 @@

, canvas = stat.find('canvas').get(0)
, ctx = canvas.getContext('2d')
, progress = new Progress;
, ctx, progress
if (canvas.getContext) {
ctx = canvas.getContext('2d');
progress = new Progress;
}
if (!root.length) return error('#mocha div missing, add it to your document');
progress.size(50);
if (progress) {
progress.size(50);
}
runner.on('suite', function(suite){

@@ -1155,4 +1164,6 @@ if (suite.root) return;

// update progress bar
progress.update(percent).draw(ctx);
if (progress) {
// update progress bar
progress.update(percent).draw(ctx);
}

@@ -1173,2 +1184,9 @@ // update stats

var str = test.err.stack || test.err;
// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
// check for the result of the stringifying.
if ('[object Error]' == str) {
str = test.err.message;
}
var err = $('<pre class="error">' + str + '</pre>');

@@ -1219,2 +1237,3 @@ el.append(err);

}
}); // module: reporters/html.js

@@ -2003,2 +2022,3 @@

, Test = require('./test')
, utils = require('./utils')
, noop = function(){};

@@ -2040,3 +2060,3 @@

this.grep(/.*/);
this.globals(Object.keys(global).concat(['errno']));
this.globals(utils.keys(global).concat(['errno']));
}

@@ -2076,3 +2096,3 @@

debug('globals %j', arr);
arr.forEach(function(arr){
utils.forEach(arr, function(arr){
this._globals.push(arr);

@@ -2092,4 +2112,4 @@ }, this);

var leaks = Object.keys(global).filter(function(key){
return !~this._globals.indexOf(key);
var leaks = utils.filter(utils.keys(global), function(key){
return !~utils.indexOf(this._globals, key);
}, this);

@@ -2425,2 +2445,3 @@

, debug = require('browser/debug')('suite')
, utils = require('./utils')
, Hook = require('./hook');

@@ -2636,3 +2657,3 @@

Suite.prototype.total = function(){
return this.suites.reduce(function(sum, suite){
return utils.reduce(this.suites, function(sum, suite){
return sum + suite.total();

@@ -2699,2 +2720,96 @@ }, 0) + this.tests.length;

};
/**
* Array#forEach (<=IE8)
*
* @param {Array} array
* @param {Function} fn
* @param {Object} scope
* @api private
*/
exports.forEach = function(arr, fn, scope) {
for (var i = 0, l = arr.length; i < l; i++)
fn.call(scope, arr[i], i);
};
/**
* Array#indexOf (<=IE8)
*
* @parma {Array} arr
* @param {Object} obj to find index of
* @param {Number} start
* @api private
*/
exports.indexOf = function (arr, obj, start) {
for (var i = start || 0, l = arr.length; i < l; i++) {
if (arr[i] === obj)
return i;
}
return -1;
};
/**
* Array#reduce (<=IE8)
*
* @param {Array} array
* @param {Function} fn
* @param {Object} initial value
* @param {Object} scope
* @api private
*/
exports.reduce = function(arr, fn, val, scope) {
var rval = val;
for (var i = 0, l = arr.length; i < l; i++) {
rval = fn.call(scope, rval, arr[i], i, arr);
}
return rval;
};
/**
* Array#filter (<=IE8)
*
* @param {Array} array
* @param {Function} fn
* @param {Object} scope
* @api private
*/
exports.filter = function(arr, fn, scope) {
var ret = [];
for (var i = 0, l = arr.length; i < l; i++) {
var val = arr[i];
if (fn.call(scope, val, i, arr))
ret.push(val);
}
return ret;
};
/**
* Object.keys (<=IE8)
*
* @param {Object} obj
* @return {Array} keys
* @api private
*/
exports.keys = Object.keys || function(obj) {
var keys = []
, has = Object.prototype.hasOwnProperty // for `window` on <=IE8
for (var i in obj) {
if (has.call(obj, i)) {
keys.push(i);
}
}
return keys;
};
}); // module: utils.js

@@ -2721,43 +2836,3 @@

}); // module: watch.js
// Only add setZeroTimeout to the window object, and hide everything else in a closure.
(function() {
var timeouts = [],
messageName = 'zero-timeout-message';
// Like setTimeout, but only takes a function argument. There's
// no time argument (always zero) and no arguments (you have to
// use a closure).
function setZeroTimeoutPostMessage(fn) {
timeouts.push(fn);
window.postMessage(messageName, '*');
}
function setZeroTimeout(fn) {
setTimeout(fn, 0);
}
function handleMessage(event) {
if (event.source == window && event.data == messageName) {
if (event.stopPropagation) {
event.stopPropagation();
}
if (timeouts.length) {
timeouts.shift()();
}
}
}
if (window.postMessage) {
if (window.addEventListener) {
window.addEventListener('message', handleMessage, true);
} else if (window.attachEvent) {
window.attachEvent('onmessage', handleMessage);
}
window.setZeroTimeout = setZeroTimeoutPostMessage;
} else {
window.setZeroTimeout = setZeroTimeout;
}
}());
/**

@@ -2775,8 +2850,29 @@ * Node shims.

process.stdout = {};
global = this;
global = window;
process.nextTick = setZeroTimeout;
process.nextTick = (function(){
// postMessage behaves badly on IE8
if (window.ActiveXObject || !window.postMessage) {
return function(fn){ fn() };
}
process.removeListener = function(ev){
if ('uncaughtException' == ev) {
// based on setZeroTimeout by David Baron
// - http://dbaron.org/log/20100309-faster-timeouts
var timeouts = []
, name = 'mocha-zero-timeout'
return function(fn){
timeouts.push(fn);
window.postMessage(name, '*');
window.addEventListener('message', function(e){
if (e.source == window && e.data == name) {
if (e.stopPropagation) e.stopPropagation();
if (timeouts.length) timeouts.shift()();
}
}, true);
}
})();
process.removeListener = function(e){
if ('uncaughtException' == e) {
window.onerror = null;

@@ -2786,4 +2882,4 @@ }

process.on = function(ev, fn){
if ('uncaughtException' == ev) {
process.on = function(e, fn){
if ('uncaughtException' == e) {
window.onerror = fn;

@@ -2793,14 +2889,12 @@ }

mocha = require('mocha');
window.mocha = require('mocha');
// boot
;(function(){
var suite = new mocha.Suite;
var Reporter = mocha.reporters.HTML;
var suite = new mocha.Suite
, utils = mocha.utils
, Reporter = mocha.reporters.HTML
function parse(qs) {
return qs
.replace('?', '')
.split('&')
.reduce(function(obj, pair){
return utils.reduce(qs.replace('?', '').split('&'), function(obj, pair){
var i = pair.indexOf('=')

@@ -2819,3 +2913,3 @@ , key = pair.slice(0, i)

ui(suite);
suite.emit('pre-require', global);
suite.emit('pre-require', window);
};

@@ -2822,0 +2916,0 @@

{
"name": "mocha"
, "version": "0.6.0"
, "version": "0.7.0"
, "description": "simple, flexible, fun test framework"

@@ -5,0 +5,0 @@ , "keywords": ["test", "bdd", "tdd", "tap"]

@@ -129,3 +129,3 @@

return function(p){
if ('.' != p[0]) return require(p);
if ('.' != p.charAt(0)) return require(p);

@@ -153,2 +153,2 @@ var path = parent.split('/')

}
};
};

@@ -14,8 +14,29 @@

process.stdout = {};
global = this;
global = window;
process.nextTick = setZeroTimeout;
process.nextTick = (function(){
// postMessage behaves badly on IE8
if (window.ActiveXObject || !window.postMessage) {
return function(fn){ fn() };
}
process.removeListener = function(ev){
if ('uncaughtException' == ev) {
// based on setZeroTimeout by David Baron
// - http://dbaron.org/log/20100309-faster-timeouts
var timeouts = []
, name = 'mocha-zero-timeout'
return function(fn){
timeouts.push(fn);
window.postMessage(name, '*');
window.addEventListener('message', function(e){
if (e.source == window && e.data == name) {
if (e.stopPropagation) e.stopPropagation();
if (timeouts.length) timeouts.shift()();
}
}, true);
}
})();
process.removeListener = function(e){
if ('uncaughtException' == e) {
window.onerror = null;

@@ -25,4 +46,4 @@ }

process.on = function(ev, fn){
if ('uncaughtException' == ev) {
process.on = function(e, fn){
if ('uncaughtException' == e) {
window.onerror = fn;

@@ -32,14 +53,12 @@ }

mocha = require('mocha');
window.mocha = require('mocha');
// boot
;(function(){
var suite = new mocha.Suite;
var Reporter = mocha.reporters.HTML;
var suite = new mocha.Suite
, utils = mocha.utils
, Reporter = mocha.reporters.HTML
function parse(qs) {
return qs
.replace('?', '')
.split('&')
.reduce(function(obj, pair){
return utils.reduce(qs.replace('?', '').split('&'), function(obj, pair){
var i = pair.indexOf('=')

@@ -58,3 +77,3 @@ , key = pair.slice(0, i)

ui(suite);
suite.emit('pre-require', global);
suite.emit('pre-require', window);
};

@@ -61,0 +80,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc