Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
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.0.1 to 0.0.2

lib/utils.js

8

History.md
0.0.2 / 2011-11-22
==================
* Fixed global leak detection due to Safari bind() change
* Fixed: escape html entities in Doc reporter
* Fixed: escape html entities in HTML reporter
* Fixed pending test support for HTML reporter. Closes #66
0.0.1 / 2011-11-22

@@ -3,0 +11,0 @@ ==================

2

lib/mocha.js

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

exports.version = '0.0.1';
exports.version = '0.0.2';

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

@@ -6,3 +6,4 @@

var Base = require('./base');
var Base = require('./base')
, utils = require('../utils');

@@ -53,3 +54,3 @@ /**

console.log('%s <dt>%s</dt>', indent(), test.title);
var code = clean(test.fn.toString());
var code = utils.escape(clean(test.fn.toString()));
console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);

@@ -56,0 +57,0 @@ });

@@ -6,3 +6,4 @@

var Base = require('./base');
var Base = require('./base')
, utils = require('../utils');

@@ -73,2 +74,4 @@ /**

var el = $('<div class="test pass"><h2>' + test.title + '</h2></div>')
} else if (test.pending) {
var el = $('<div class="test pass pending"><h2>' + test.title + '</h2></div>')
} else {

@@ -90,4 +93,7 @@ var el = $('<div class="test fail"><h2>' + test.title + '</h2></div>');

// TODO: defer
var pre = $('<pre><code>' + clean(test.fn.toString()) + '</code></pre>');
pre.appendTo(el).hide();
if (!test.pending) {
var code = utils.escape(clean(test.fn.toString()));
var pre = $('<pre><code>' + code + '</code></pre>');
pre.appendTo(el).hide();
}
stack[0].append(el);

@@ -94,0 +100,0 @@ });

@@ -38,3 +38,3 @@

this.globals = Object.keys(global).concat(['errno']);
this.on('test end', function(){ self.checkGlobals(); });
this.on('test end', function(test){ self.checkGlobals(test); });
this.grep(/.*/);

@@ -41,0 +41,0 @@ }

@@ -363,3 +363,3 @@

exports.version = '0.0.1-alpha5';
exports.version = '0.0.1';

@@ -406,2 +406,5 @@ exports.interfaces = require('./interfaces');

, 'fail': 31
, 'bright pass': 92
, 'bright fail': 91
, 'bright yellow': 93
, 'pending': 36

@@ -416,2 +419,4 @@ , 'suite': '40'

, 'slow': 31
, 'green': 32
, 'light': 90
};

@@ -566,3 +571,4 @@

Base.prototype.epilogue = function(){
var stats = this.stats;
var stats = this.stats
, fmt;

@@ -573,5 +579,7 @@ console.log();

if (stats.failures) {
console.error(
' \033[91m✖\033[31m %d of %d tests failed\033[90m:\033[0m'
, stats.failures, stats.tests);
fmt = color('bright fail', ' ✖')
+ color('fail', ' %d of %d tests failed')
+ color('light', ':')
console.error(fmt, stats.failures, stats.tests);
Base.list(this.failures);

@@ -586,7 +594,7 @@ console.error();

// pass
console.log(
' \033[92m✔\033[32m %d tests completed\033[90m (%dms)\033[0m'
, stats.tests || 0
, stats.duration);
fmt = color('bright pass', ' ✔')
+ color('green', ' %d tests complete')
+ color('light', ' (%dms)');
console.log(fmt, stats.tests || 0, stats.duration);
console.log();

@@ -606,3 +614,4 @@ process.nextTick(function(){

var Base = require('./base');
var Base = require('./base')
, utils = require('../utils');

@@ -653,3 +662,3 @@ /**

console.log('%s <dt>%s</dt>', indent(), test.title);
var code = clean(test.fn.toString());
var code = utils.escape(clean(test.fn.toString()));
console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);

@@ -723,3 +732,3 @@ });

if ('slow' == test.speed) {
process.stdout.write('\033[93m.\033[0m');
process.stdout.write(color('bright yellow', '.'));
} else {

@@ -756,3 +765,4 @@ process.stdout.write(color(test.speed, '.'));

var Base = require('./base');
var Base = require('./base')
, utils = require('../utils');

@@ -823,2 +833,4 @@ /**

var el = $('<div class="test pass"><h2>' + test.title + '</h2></div>')
} else if (test.pending) {
var el = $('<div class="test pass pending"><h2>' + test.title + '</h2></div>')
} else {

@@ -840,4 +852,7 @@ var el = $('<div class="test fail"><h2>' + test.title + '</h2></div>');

// TODO: defer
var pre = $('<pre><code>' + clean(test.fn.toString()) + '</code></pre>');
pre.appendTo(el).hide();
if (!test.pending) {
var code = utils.escape(clean(test.fn.toString()));
var pre = $('<pre><code>' + code + '</code></pre>');
pre.appendTo(el).hide();
}
stack[0].append(el);

@@ -1592,2 +1607,78 @@ });

/**
* Run hook `name` for the given array of `suites`
* in order, and callback `fn(err)`.
*
* @param {String} name
* @param {Array} suites
* @param {Function} fn
* @api private
*/
Runner.prototype.hooks = function(name, suites, fn){
var self = this
, orig = this.suite;
function next(suite) {
self.suite = suite;
if (!suite) {
self.suite = orig;
return fn();
}
self.hook(name, function(err){
if (err) {
self.suite = orig;
return fn(err);
}
next(suites.pop());
});
}
next(suites.pop());
};
/**
* Run hooks from the top level down.
*
* @param {String} name
* @param {Function} fn
* @api private
*/
Runner.prototype.hookUp = function(name, fn){
var suites = [this.suite].concat(this.parents()).reverse();
this.hooks(name, suites, fn);
};
/**
* Run hooks from the bottom up.
*
* @param {String} name
* @param {Function} fn
* @api private
*/
Runner.prototype.hookDown = function(name, fn){
var suites = [this.suite].concat(this.parents());
this.hooks(name, suites, fn);
};
/**
* Return an array of parent Suites from
* closest to furthest.
*
* @return {Array}
* @api private
*/
Runner.prototype.parents = function(){
var suite = this.suite
, suites = [];
while (suite = suite.parent) suites.push(suite);
return suites;
};
/**
* Run the current test and callback `fn(err)`.

@@ -1668,3 +1759,3 @@ *

self.emit('test', self.test = test);
self.hook('beforeEach', function(err){
self.hookDown('beforeEach', function(err){
if (err) return self.failHook('beforeEach', err);

@@ -1677,3 +1768,3 @@ self.runTest(function(err){

if (err) return self.failHook('beforeEach', err);
self.hook('afterEach', function(err){
self.hookUp('afterEach', function(err){
if (err) return self.failHook('afterEach', err);

@@ -1744,2 +1835,3 @@ next();

self.fail(self.test, err);
self.emit('test end', self.test);
self.emit('end');

@@ -1822,5 +1914,5 @@ });

/**
* Set timeout `ms`.
* Set timeout `ms` or short-hand such as "2s".
*
* @param {Number} ms
* @param {Number|String} ms
* @return {Suite} for chaining

@@ -1831,3 +1923,4 @@ * @api private

Suite.prototype.timeout = function(ms){
this._timeout = ms;
if (String(ms).match(/s$/)) ms = parseFloat(ms) * 1000;
this._timeout = parseInt(ms, 10);
return this;

@@ -2042,3 +2135,22 @@ };

require.register("utils.js", function(module, exports, require){
/**
* Escape special characters in the given string of html.
*
* @param {String} html
* @return {String}
* @api private
*/
exports.escape = function(html) {
return String(html)
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
};
}); // module: utils.js
/**
* Node shims.

@@ -2045,0 +2157,0 @@ *

{
"name": "mocha"
, "version": "0.0.1"
, "version": "0.0.2"
, "description": "Test framework inspired by JSpec, Expresso, & Qunit"

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

@@ -8,2 +8,4 @@ describe('Array', function(){

it('should be pending')
it('should return the correct index when the value is present', function(){

@@ -10,0 +12,0 @@ var arr = [1,2,3];

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