Socket
Socket
Sign inDemoInstall

mocha

Package Overview
Dependencies
3
Maintainers
1
Versions
192
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.3 to 0.3.4

lib/browser/debug.js

16

History.md
0.3.5 / 2011-12-08
==================
* Added support for `window.onerror` [guillermo]
* Fixed: clear timeout on uncaught exceptions. Closes #131 [guillermo]
* Added `mocha.css` to PHONY list.
* Added `mocha.js` to PHONY list.
0.3.4 / 2011-12-08
==================
* Added: allow `done()` to be called with non-Error
* Added: return Runner from `mocha.run()`. Closes #126
* Fixed: run afterEach even on failures. Closes #125
* Fixed clobbering of current runnable. Closes #121
0.3.3 / 2011-12-08

@@ -3,0 +19,0 @@ ==================

2

lib/mocha.js

@@ -12,3 +12,3 @@

exports.version = '0.3.3';
exports.version = '0.3.5';

@@ -15,0 +15,0 @@ exports.interfaces = require('./interfaces');

@@ -65,2 +65,12 @@

/**
* Clear the timeout.
*
* @api private
*/
Runnable.prototype.clearTimeout = function(){
clearTimeout(this.timer);
};
/**
* Run the test and invoke `fn(err)`.

@@ -77,8 +87,7 @@ *

, finished
, emitted
, timer;
, emitted;
// timeout
if (this.async) {
timer = setTimeout(function(){
this.timer = setTimeout(function(){
done(new Error('timeout of ' + ms + 'ms exceeded'));

@@ -98,3 +107,3 @@ }, ms);

if (finished) return multiple();
clearTimeout(timer);
self.clearTimeout();
self.duration = new Date - start;

@@ -108,3 +117,6 @@ finished = true;

try {
this.fn(done);
this.fn(function(err){
if (err instanceof Error) return done(err);
done();
});
} catch (err) {

@@ -111,0 +123,0 @@ done(err);

@@ -155,4 +155,5 @@

function next(i) {
var hook = self.currentRunnable = hooks[i];
var hook = hooks[i];
if (!hook) return fn();
self.currentRunnable = hook;

@@ -290,8 +291,2 @@ self.emit('hook', hook);

function next(err) {
// error handling
if (err) {
self.fail(test, err);
self.emit('test end', test);
}
// next test

@@ -317,3 +312,8 @@ test = tests.shift();

self.runTest(function(err){
if (err) return next(err);
if (err) {
self.fail(test, err);
self.emit('test end', test);
return self.hookUp('afterEach', next);
}
self.emit('pass', test);

@@ -370,2 +370,3 @@ test.passed = true;

* @param {Function} fn
* @return {Runner} for chaining
* @api public

@@ -397,2 +398,3 @@ */

debug('uncaught exception');
self.currentRunnable.clearTimeout();
self.fail(self.currentRunnable, err);

@@ -399,0 +401,0 @@ self.emit('test end', self.test);

@@ -49,2 +49,11 @@

require.register("browser/debug.js", function(module, exports, require){
module.exports = function(type){
return function(){
}
};
}); // module: browser/debug.js
require.register("browser/events.js", function(module, exports, require){

@@ -428,3 +437,3 @@

exports.version = '0.3.0';
exports.version = '0.3.5';

@@ -560,3 +569,4 @@ exports.interfaces = require('./interfaces');

, stack = err.stack
, index = stack.indexOf(err.message) + err.message.length
, message = err.message || ''
, index = stack.indexOf(message) + message.length
, msg = stack.slice(0, index);

@@ -946,2 +956,3 @@

exports.List = require('./list');
exports.Spec = require('./spec');
exports.Progress = require('./progress');

@@ -1491,3 +1502,4 @@ exports.Landing = require('./landing');

var EventEmitter = require('browser/events').EventEmitter;
var EventEmitter = require('browser/events').EventEmitter
, debug = require('browser/debug')('runnable');

@@ -1513,3 +1525,3 @@ /**

this.sync = ! this.async;
this.timeout(2000);
this._timeout = 2000;
}

@@ -1535,2 +1547,3 @@

if (0 == arguments.length) return this._timeout;
debug('timeout %d', ms);
this._timeout = ms;

@@ -1553,2 +1566,12 @@ return this;

/**
* Clear the timeout.
*
* @api private
*/
Runnable.prototype.clearTimeout = function(){
clearTimeout(this.timer);
};
/**
* Run the test and invoke `fn(err)`.

@@ -1565,8 +1588,7 @@ *

, finished
, emitted
, timer;
, emitted;
// timeout
if (this.async) {
timer = setTimeout(function(){
this.timer = setTimeout(function(){
done(new Error('timeout of ' + ms + 'ms exceeded'));

@@ -1586,3 +1608,3 @@ }, ms);

if (finished) return multiple();
clearTimeout(timer);
self.clearTimeout();
self.duration = new Date - start;

@@ -1596,3 +1618,6 @@ finished = true;

try {
this.fn(done);
this.fn(function(err){
if (err instanceof Error) return done(err);
done();
});
} catch (err) {

@@ -1623,2 +1648,3 @@ done(err);

var EventEmitter = require('browser/events').EventEmitter
, debug = require('browser/debug')('runner')
, Test = require('./test')

@@ -1681,2 +1707,3 @@ , noop = function(){};

Runner.prototype.grep = function(re){
debug('grep %s', re);
this._grep = re;

@@ -1695,2 +1722,3 @@ return this;

Runner.prototype.globals = function(arr){
debug('globals %j', arr);
arr.forEach(function(arr){

@@ -1775,2 +1803,3 @@ this._globals.push(arr);

if (!hook) return fn();
self.currentRunnable = hook;

@@ -1784,2 +1813,3 @@ self.emit('hook', hook);

hook.run(function(err){
hook.removeAllListeners('error');
if (err) return self.failHook(hook, err);

@@ -1908,8 +1938,2 @@ self.emit('hook end', hook);

function next(err) {
// error handling
if (err) {
self.fail(test, err);
self.emit('test end', test);
}
// next test

@@ -1932,6 +1956,11 @@ test = tests.shift();

// execute test and hook(s)
self.emit('test', self.test = test);
self.emit('test', self.test = self.currentRunnable = test);
self.hookDown('beforeEach', function(){
self.runTest(function(err){
if (err) return next(err);
if (err) {
self.fail(test, err);
self.emit('test end', test);
return self.hookUp('afterEach', next);
}
self.emit('pass', test);

@@ -1961,2 +1990,3 @@ test.passed = true;

debug('run suite %s', suite.fullTitle());
this.emit('suite', this.suite = suite);

@@ -1988,2 +2018,3 @@

* @param {Function} fn
* @return {Runner} for chaining
* @api public

@@ -1996,4 +2027,7 @@ */

debug('start');
// callback
self.on('end', function(){
debug('end');
process.removeListener('uncaughtException', uncaught);

@@ -2006,2 +2040,3 @@ fn(self.failures);

this.runSuite(this.suite, function(){
debug('finished running');
self.emit('end');

@@ -2012,3 +2047,5 @@ });

function uncaught(err){
self.fail(self.test, err);
debug('uncaught exception');
self.currentRunnable.clearTimeout();
self.fail(self.currentRunnable, err);
self.emit('test end', self.test);

@@ -2032,2 +2069,3 @@ self.emit('end');

var EventEmitter = require('browser/events').EventEmitter
, debug = require('browser/debug')('suite')
, Hook = require('./hook');

@@ -2095,3 +2133,3 @@

this.root = !title;
this.timeout(2000);
this._timeout = 2000;
}

@@ -2116,3 +2154,4 @@

var suite = new Suite(this.title);
suite.timeout(this._timeout);
debug('clone');
suite.timeout(this.timeout());
return suite;

@@ -2125,3 +2164,3 @@ };

* @param {Number|String} ms
* @return {Suite} for chaining
* @return {Suite|Number} for chaining
* @api private

@@ -2131,3 +2170,5 @@ */

Suite.prototype.timeout = function(ms){
if (0 == arguments.length) return this._timeout;
if (String(ms).match(/s$/)) ms = parseFloat(ms) * 1000;
debug('timeout %d', ms);
this._timeout = parseInt(ms, 10);

@@ -2148,2 +2189,3 @@ return this;

hook.parent = this;
hook.timeout(this.timeout());
this._beforeAll.push(hook);

@@ -2165,2 +2207,3 @@ this.emit('beforeAll', hook);

hook.parent = this;
hook.timeout(this.timeout());
this._afterAll.push(hook);

@@ -2182,2 +2225,3 @@ this.emit('afterAll', hook);

hook.parent = this;
hook.timeout(this.timeout());
this._beforeEach.push(hook);

@@ -2199,2 +2243,3 @@ this.emit('beforeEach', hook);

hook.parent = this;
hook.timeout(this.timeout());
this._afterEach.push(hook);

@@ -2215,3 +2260,3 @@ this.emit('afterEach', hook);

suite.parent = this;
if (this._timeout) suite.timeout(this._timeout);
suite.timeout(this.timeout());
this.suites.push(suite);

@@ -2232,3 +2277,3 @@ this.emit('suite', suite);

test.parent = this;
if (this._timeout) test.timeout(this._timeout);
test.timeout(this.timeout());
this.tests.push(test);

@@ -2332,3 +2377,4 @@ this.emit('test', test);

var fs = require('browser/fs');
var fs = require('browser/fs')
, debug = require('browser/debug')('watch');

@@ -2338,2 +2384,3 @@ module.exports = function(paths, fn){

paths.forEach(function(path){
debug('watch %s', path);
fs.watchFile(path, options, function(curr, prev){

@@ -2356,5 +2403,2 @@ if (prev.mtime < curr.mtime) fn(path);

process = {};
process.nextTick = function(fn){ setTimeout(fn, 0); };
process.removeListener = function(fn){};
process.on = function(){};
process.exit = function(status){};

@@ -2364,2 +2408,18 @@ process.stdout = {};

process.nextTick = function(fn){
setTimeout(fn, 0);
};
process.removeListener = function(ev){
if ('uncaughtException' == ev) {
window.onerror = null;
}
};
process.on = function(ev, fn){
if ('uncaughtException' == ev) {
window.onerror = fn;
}
};
mocha = require('mocha');

@@ -2399,4 +2459,4 @@

if (query.grep) runner.grep(new RegExp(query.grep));
runner.run();
return runner.run();
};
})();
{
"name": "mocha"
, "version": "0.3.3"
, "version": "0.3.4"
, "description": "Test framework inspired by JSpec, Expresso, & Qunit"

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

@@ -47,2 +47,3 @@

.replace(/require\('events'\)/g, "require('browser/events')")
.replace(/require\('debug'\)/g, "require('browser/debug')")
.replace(/require\('tty'\)/g, "require('browser/tty')")

@@ -49,0 +50,0 @@ .replace(/require\('fs'\)/g, "require('browser/fs')")

@@ -12,5 +12,2 @@

process = {};
process.nextTick = function(fn){ setTimeout(fn, 0); };
process.removeListener = function(fn){};
process.on = function(){};
process.exit = function(status){};

@@ -20,2 +17,18 @@ process.stdout = {};

process.nextTick = function(fn){
setTimeout(fn, 0);
};
process.removeListener = function(ev){
if ('uncaughtException' == ev) {
window.onerror = null;
}
};
process.on = function(ev, fn){
if ('uncaughtException' == ev) {
window.onerror = fn;
}
};
mocha = require('mocha');

@@ -55,4 +68,4 @@

if (query.grep) runner.grep(new RegExp(query.grep));
runner.run();
return runner.run();
};
})();
var mocha = require('../')
, Runnable = mocha.Runnable;
, Runnable = mocha.Runnable
, EventEmitter = require('events').EventEmitter;

@@ -93,2 +94,10 @@ describe('Runnable(title, fn)', function(){

describe('when the callback is invoked with a non-Error', function(){
it('should pass', function(done){
var thing = new EventEmitter;
thing.on('foo', done);
thing.emit('foo', 'bar');
})
})
describe('when the callback is invoked several times', function(){

@@ -95,0 +104,0 @@ describe('without an error', function(){

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc