Comparing version 0.9.0 to 0.9.1
@@ -12,2 +12,3 @@ /** | ||
'--timeout timeout for async tests', | ||
'--plugins specify plugin(s) to use', | ||
'--setup specify setup file(s) to use', | ||
@@ -14,0 +15,0 @@ '--stack-limit stack trace limit', |
@@ -5,3 +5,2 @@ { | ||
"description": "", | ||
"version": "0.9.0", | ||
"license": "MIT", | ||
@@ -12,3 +11,3 @@ "main": "lib/hydro.js", | ||
"vesln/evts": "0.1.0", | ||
"vesln/tryc": "0.0.3", | ||
"vesln/tryc": "0.1.0", | ||
"vesln/fload": "0.0.2", | ||
@@ -15,0 +14,0 @@ "vesln/globalo": "0.0.1", |
@@ -1107,2 +1107,22 @@ ;(function(){ | ||
/** | ||
* Return the titles of all parent suites + | ||
* the test title. | ||
* | ||
* @returns {String} | ||
* @api public | ||
*/ | ||
Base.prototype.fullTitle = function() { | ||
var parents = this.parents().splice(1); | ||
var fullTitle = []; | ||
for (var i = 0, len = parents.length; i < len; i++) { | ||
fullTitle.push(parents[i].title); | ||
} | ||
fullTitle.push(this.title); | ||
return fullTitle.join(' '); | ||
}; | ||
/** | ||
* Run the test. | ||
@@ -1189,2 +1209,3 @@ * | ||
var AsyncTest = require('./async'); | ||
var BaseTest = require('./base'); | ||
@@ -1220,2 +1241,8 @@ /** | ||
/** | ||
* Export `BaseTest`. | ||
*/ | ||
exports.BaseTest = BaseTest; | ||
}); | ||
@@ -1222,0 +1249,0 @@ require.register("hydro/lib/hydro/test/sync.js", function(exports, require, module){ |
@@ -1,1 +0,1 @@ | ||
(function(){function require(path,parent,orig){var resolved=require.resolve(path);if(null==resolved){orig=orig||path;parent=parent||"root";var err=new Error('Failed to require "'+orig+'" from "'+parent+'"');err.path=orig;err.parent=parent;err.require=true;throw err}var module=require.modules[resolved];if(!module._resolving&&!module.exports){var mod={};mod.exports={};mod.client=mod.component=true;module._resolving=true;module.call(this,mod.exports,require.relative(resolved),mod);delete module._resolving;module.exports=mod.exports}return module.exports}require.modules={};require.aliases={};require.resolve=function(path){if(path.charAt(0)==="/")path=path.slice(1);var paths=[path,path+".js",path+".json",path+"/index.js",path+"/index.json"];for(var i=0;i<paths.length;i++){var path=paths[i];if(require.modules.hasOwnProperty(path))return path;if(require.aliases.hasOwnProperty(path))return require.aliases[path]}};require.normalize=function(curr,path){var segs=[];if("."!=path.charAt(0))return path;curr=curr.split("/");path=path.split("/");for(var i=0;i<path.length;++i){if(".."==path[i]){curr.pop()}else if("."!=path[i]&&""!=path[i]){segs.push(path[i])}}return curr.concat(segs).join("/")};require.register=function(path,definition){require.modules[path]=definition};require.alias=function(from,to){if(!require.modules.hasOwnProperty(from)){throw new Error('Failed to alias "'+from+'", it does not exist')}require.aliases[to]=from};require.relative=function(parent){var p=require.normalize(parent,"..");function lastIndexOf(arr,obj){var i=arr.length;while(i--){if(arr[i]===obj)return i}return-1}function localRequire(path){var resolved=localRequire.resolve(path);return require(resolved,parent,path)}localRequire.resolve=function(path){var c=path.charAt(0);if("/"==c)return path.slice(1);if("."==c)return require.normalize(p,path);var segs=parent.split("/");var i=lastIndexOf(segs,"deps")+1;if(!i)i=0;path=segs.slice(0,i+1).join("/")+"/deps/"+path;return path};localRequire.exists=function(path){return require.modules.hasOwnProperty(localRequire.resolve(path))};return localRequire};require.register("hydrojs-loa/index.js",function(exports,require,module){var root=typeof global!=="undefined"?global:window;var toString=Object.prototype.toString;function is(type,input){if(type==="Object")return Object(input)===input;return toString.call(input)==="[object "+type+"]"}function str(input){if(!is("String",input))return;return root[input]||(root.require||require)(input)}function handeled(input){if(is("Object",input)||is("Function",input))return input}function raise(input){throw new TypeError("loa: Can't handle: "+input)}function loa(input){return handeled(input)||str(input)||raise(input)}module.exports=loa});require.register("vesln-evts/lib/evts.js",function(exports,require,module){var slice=Array.prototype.slice;function EventEmitter(){this.events={}}EventEmitter.prototype.on=function(evt,fn){this.events[evt]=this.events[evt]||[];this.events[evt].push(fn)};EventEmitter.prototype.emit=function(evt,fn){var listeners=this.events[evt];var i=0;var args=slice.call(arguments,1);var done=args.pop();if(!listeners)return done();(function next(err){if(err)return done(err);var handler=listeners[i];if(!handler)return done();i++;if(handler.length>args.length)return handler.apply(null,args.concat(next));try{handler.apply(null,args)}catch(e){return next(e)}next()})()};module.exports=EventEmitter});require.register("vesln-tryc/lib/browser.js",function(exports,require,module){module.exports=function(fn,end){var prev=window.onerror;function handler(err){window.onerror=prev;end(err)}window.onerror=function(msg,url,line){handler(new Error(msg+" at "+url+":"+line))};try{fn(handler)}catch(err){handler(err)}}});require.register("vesln-fload/lib/browser.js",function(exports,require,module){function load(files,callbacks){var target=document.getElementsByTagName("script")[0];files=files.slice(0);(function next(){var file=files.shift();if(!file)return callbacks.done();callbacks.pre(file,function(){var script=document.createElement("script");script.src=file;script.onload=script.onreadystatechange=function(e){if(e&&e.type==="load"||/loaded|complete/.test(script.readyState)){script.onload=null;script.onreadystatechange=null;callbacks.post(file,null,next)}};target.parentNode.insertBefore(script,target)})})()}module.exports=load});require.register("vesln-globalo/index.js",function(exports,require,module){module.exports=function(){if(typeof global!=="undefined"){return global}else if(typeof window!=="undefined"){return window}else if(typeof Alloy!=="undefined"&&typeof Alloy.Globals!=="undefined"){return Alloy.Globals}else if(typeof Ti!=="undefined"&&typeof Ti.App!=="undefined"){return Ti.App}}});require.register("vesln-super/lib/super.js",function(exports,require,module){var slice=Array.prototype.slice;var exports=module.exports=super_;function super_(){var args=slice.call(arguments);if(!args.length)return;if(typeof args[0]!=="function")return exports.merge(args);exports.inherits.apply(null,args)}exports.extend=function(proto,klass){var self=this,child=function(){return self.apply(this,arguments)};exports.merge([child,this]);exports.inherits(child,this);if(proto)exports.merge([child.prototype,proto]);if(klass)exports.merge([child,klass]);child.extend=this.extend;return child};exports.inherits=function(ctor,superCtor){ctor.super_=superCtor;if(Object.create){ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}else{ctor.prototype=new superCtor;ctor.prototype.constructor=ctor}};exports.merge=function(arr){var main=arr.length===2?arr.shift():{};var obj=null;for(var i=0,len=arr.length;i<len;i++){obj=arr[i];for(var p in obj){if(!obj.hasOwnProperty(p))continue;main[p]=obj[p]}}return main}});require.register("hydro/lib/hydro.js",function(exports,require,module){var EventEmitter=require("evts");var globalo=require("globalo");var loader=require("fload");var merge=require("super").merge;var loa=require("loa");var RootSuite=require("./hydro/suite/root");var Interface=require("./hydro/interface");var Suite=require("./hydro/suite");var Test=require("./hydro/test");var util=require("./hydro/util");function Hydro(){if(!(this instanceof Hydro))return new Hydro;this.loader=loader;this.plugins=[];this.options={plugins:[],aliases:{},globals:{},tests:[]};this.root=new RootSuite;this.emitter=new EventEmitter;this.interface=new Interface(this)}Hydro.prototype.set=function(key,val){if(Object(key)===key){this.options=merge([this.options,key])}else if(arguments.length===3){if(typeof this.options[key]==="undefined"){this.options[key]={}}this.options[key][val]=arguments[2]}else{this.options[key]=val}};Hydro.prototype.push=function(key,val){if(typeof this.options[key]==="undefined"){this.options[key]=[]}this.options[key].push(val)};Hydro.prototype.get=function(key){return this.options[key]};Hydro.prototype.on=function(evt,fn){this.emitter.on(evt,fn)};Hydro.prototype.suites=function(){var suites=[];this.traverse({enterSuite:function(suite){suites.push(suite)}});return suites};Hydro.prototype.tests=function(){var tests=[];this.traverse({test:function(test){tests.push(test)}});return tests};Hydro.prototype.traverse=function(handlers){handlers.test=handlers.test||util.noop;handlers.enterSuite=handlers.enterSuite||util.noop;handlers.leaveSuite=handlers.leaveSuite||util.noop;(function next(suite){handlers.enterSuite(suite);util.forEach(suite.suites,next);util.forEach(suite.tests,handlers.test);handlers.leaveSuite(suite)})(this.root)};Hydro.prototype.setup=function(){var emitter=this.emitter;var suite=null;var stackLimit=null;var self=this;this.loadPlugins();this.attachGlobals();this.attachProxies();this.loadFormatter();if(suite=this.get("suite")){this.interface.pushSuite(suite)}if(stackLimit=this.get("stackLimit")){Error.stackTraceLimit=stackLimit}this._init=true};Hydro.prototype.exec=function(fn){var emitter=this.emitter;var self=this;var suite=this.get("suite");fn=fn||function(){};this.loader(this.get("tests"),{pre:function(file,done){emitter.emit("pre:file",file,done)},post:function(file,contents,done){emitter.emit("post:file",file,done)},done:function(){if(suite)self.interface.popSuite();self.root.run(emitter,fn)}})};Hydro.prototype.run=function(fn){if(!this._init)this.setup();this.exec(fn)};Hydro.prototype.loadPlugins=function(){util.forEach(this.get("plugins"),function(plugin){plugin=loa(plugin);plugin(this,util);this.plugins.push(plugin)},this)};Hydro.prototype.createTest=function(){var test=Test.create(util.slice(arguments));var timeout=this.get("timeout");if(timeout)test.timeout(timeout);return test};Hydro.prototype.createSuite=function(title){return new Suite(title)};util.forEach(["addTest","addSuite"],function(method){Hydro.prototype[method]=function(){return this.interface[method].apply(this.interface,arguments)}});Hydro.prototype.attachGlobals=function(){var target=this.global();util.eachKey(this.get("globals"),function(key,val){target[key]=val})};Hydro.prototype.attachProxies=function(){var proxies=this.get("proxies");var target=this.global();var self=this;util.eachKey(proxies,function(key,val){target[key]=function(){return self.interface[val].apply(self.interface,arguments)}})};Hydro.prototype.global=function(){return this.get("attach")||globalo()};Hydro.prototype.loadFormatter=function(){var name=this.get("formatter");var formatter=null;if(!name)return;formatter=loa(name);if(util.isFunction(formatter))formatter=new formatter;formatter.use(this)};module.exports=Hydro;module.exports.util=util;module.exports.Test=Test;module.exports.Suite=Suite});require.register("hydro/lib/hydro/test/async.js",function(exports,require,module){var tryc=require("tryc");var sTimeout=setTimeout;var BaseTest=require("./base");var AsyncTest=BaseTest.extend();AsyncTest.prototype._timeout=1e3*2;AsyncTest.prototype.async=true;AsyncTest.prototype.exec=function(done){var timeout=null;var ended=false;var fn=this.fn;var context=this.context;function end(err){if(ended)return;ended=true;clearTimeout(timeout);done(err)}timeout=sTimeout(function(){end(new Error("Test timed out"))},this._timeout);tryc(function(done){fn.call(context,done)},end)};module.exports=AsyncTest});require.register("hydro/lib/hydro/test/base.js",function(exports,require,module){var extend=require("super").extend;var inherits=require("super");var Emitter=require("evts");var util=require("../util");var D=Date;function Base(title,fn,meta){this.title=title;this.fn=fn;this.meta=util.toArray(meta||[]);this.status=null;this.error=null;this.time=null;this.context={};this.events={pre:"pre:test",post:"post:test"};if(!this.fn)this.pending()}Base.extend=extend;inherits(Base,Emitter);Base.prototype.timeout=function(ms){this._timeout=ms;return this};Base.prototype.skip=function(condition){if(arguments.length&&!condition)return;this.status="skipped";this.time=0};Base.prototype.pending=function(){this.status="pending";this.time=0;return this};Base.prototype.run=function(emitter,done){var self=this;var events=this.events;emitter.emit(events.pre,this,function(){var disabled=self.status==="pending"||self.status==="skipped";if(disabled)return emitter.emit(events.post,self,done);self.emit("before",function(err){if(err)return done(err);var start=(new D).getTime();self.exec(function(err){self.time=(new D).getTime()-start;if(err)self.fail(err);else self.pass();self.emit("after",function(err){if(err)return done(err);emitter.emit(events.post,self,done)})})})})};Base.prototype.parents=function(){return this.suite.parents().concat(this.suite)};Base.prototype.fail=function(err){this.status="failed";this.error=err;return this};Base.prototype.pass=function(){this.status="passed";return this};module.exports=Base});require.register("hydro/lib/hydro/test/index.js",function(exports,require,module){var SyncTest=require("./sync");var AsyncTest=require("./async");exports.create=function(params){var title=params.shift();var fn=null;var klass=null;if(typeof params[params.length-1]==="function")fn=params.pop();klass=fn&&fn.length?AsyncTest:SyncTest;return new klass(title,fn,params)};exports.SyncTest=SyncTest;exports.AsyncTest=AsyncTest});require.register("hydro/lib/hydro/test/sync.js",function(exports,require,module){var BaseTest=require("./base");var SyncTest=BaseTest.extend();SyncTest.prototype.sync=true;SyncTest.prototype.exec=function(done){var err=null;try{this.fn.call(this.context)}catch(e){err=e}done(err)};module.exports=SyncTest});require.register("hydro/lib/hydro/suite/index.js",function(exports,require,module){var inherits=require("super");var Emitter=require("evts");var util=require("../util");function Suite(title){this.title=util.isFunction(title)?util.fnName(title):title;this.parent=null;this.tests=[];this.suites=[];this.events={pre:"pre:suite",post:"post:suite"}}inherits(Suite,Emitter);Suite.prototype.addTest=function(test){test.suite=this;this.tests.push(test)};Suite.prototype.addSuite=function(suite){suite.parent=this;this.suites.push(suite)};Suite.prototype.run=function(emitter,fn){var self=this;var runnable=this.tests.slice(0).concat(this.suites.slice(0));var current=null;var events=this.events;function next(err){if(err)return fn(err);if(current=runnable.shift()){return current.run(emitter,next)}self.emit("after",function(err){if(err)return fn(err);emitter.emit(events.post,self,fn)})}emitter.emit(events.pre,this,function(err){if(err)return fn(err);self.emit("before",next)})};Suite.prototype.parents=function(){return this.parent.parents().concat(this.parent)};module.exports=Suite});require.register("hydro/lib/hydro/suite/root.js",function(exports,require,module){var inherits=require("super");var Suite=require("./index");function RootSuite(){Suite.call(this);this.events={pre:"pre:all",post:"post:all"}}inherits(RootSuite,Suite);RootSuite.prototype.addTest=function(){throw new Error("Please add a test suite")};RootSuite.prototype.parents=function(){return[]};module.exports=RootSuite});require.register("hydro/lib/hydro/interface.js",function(exports,require,module){var Suite=require("./suite");var util=require("./util");function Interface(hydro){this.hydro=hydro;this.ctx=new Frame(hydro.root);this.stack=[this.ctx]}util.forEach(["createTest","createSuite"],function(method){Interface.prototype[method]=function(){return this.hydro[method].apply(this.hydro,arguments)}});Interface.prototype.addSuite=function(title,fn){var suite=this.pushSuite(title);if(fn)fn.call(suite);this.popSuite();return suite};Interface.prototype.pushSuite=function(title){var suite=!(title instanceof Suite)?this.hydro.createSuite.apply(this.hydro,arguments):title;this.ctx.suite.addSuite(suite);this.ctx=new Frame(suite);this.stack.push(this.ctx);return suite};Interface.prototype.popSuite=function(){this.ctx=this.stack[this.stack.length-2];return this.stack.pop()};Interface.prototype.addTest=function(){var test=this.hydro.createTest.apply(this.hydro,arguments);each("beforeEach",this,before);each("afterEach",this,after);util.forEach(this.ctx.beforeNext,before);this.ctx.beforeNext.length=0;util.forEach(this.ctx.afterNext,after);this.ctx.afterNext.length=0;this.ctx.suite.addTest(test);function before(fn){test.on("before",fn)}function after(fn){test.on("after",fn)}return test};Interface.prototype.beforeNext=function(fn){this.ctx.beforeNext.push(fn)};Interface.prototype.afterNext=function(fn){this.ctx.afterNext.push(fn)};Interface.prototype.before=function(fn){this.ctx.beforeEach.push(fn)};Interface.prototype.after=function(fn){this.ctx.afterEach.push(fn)};Interface.prototype.beforeAll=function(fn){this.ctx.suite.on("before",fn)};Interface.prototype.afterAll=function(fn){this.ctx.suite.on("after",fn)};function Frame(suite){this.suite=suite;this.beforeNext=[];this.beforeEach=[];this.afterEach=[];this.afterNext=[]}function each(key,interface,fn){var stack=interface.stack;for(var i=0,len=stack.length;i<len;i++){util.forEach(stack[i][key],fn)}}module.exports=Interface});require.register("hydro/lib/hydro/util.js",function(exports,require,module){var toString=Object.prototype.toString;var slice=Array.prototype.slice;exports.isString=function(str){return toString.call(str)==="[object String]"};exports.isFunction=function(fn){return toString.call(fn)==="[object Function]"};exports.isArray=function(arr){return toString.call(arr)==="[object Array]"};exports.slice=function(args){return slice.call(args)};exports.toArray=function(arr){if(exports.isArray(arr))return arr;return[arr]};exports.forEach=function(arr,fn,ctx){for(var i=0,len=arr.length;i<len;i++){fn.call(ctx,arr[i])}};exports.eachKey=function(obj,fn){for(var key in obj){if(!obj.hasOwnProperty(key))continue;fn(key,obj[key])}};exports.fnName=function(fn){if(fn.name)return fn.name;var match=/^\s?function ([^(]*)\(/.exec(fn);return match&&match[1]?match[1]:""};exports.noop=function(){}});require.alias("hydrojs-loa/index.js","hydro/deps/loa/index.js");require.alias("hydrojs-loa/index.js","hydro/deps/loa/index.js");require.alias("hydrojs-loa/index.js","loa/index.js");require.alias("hydrojs-loa/index.js","hydrojs-loa/index.js");require.alias("vesln-evts/lib/evts.js","hydro/deps/evts/lib/evts.js");require.alias("vesln-evts/lib/evts.js","hydro/deps/evts/index.js");require.alias("vesln-evts/lib/evts.js","evts/index.js");require.alias("vesln-evts/lib/evts.js","vesln-evts/index.js");require.alias("vesln-tryc/lib/browser.js","hydro/deps/tryc/lib/browser.js");require.alias("vesln-tryc/lib/browser.js","hydro/deps/tryc/index.js");require.alias("vesln-tryc/lib/browser.js","tryc/index.js");require.alias("vesln-tryc/lib/browser.js","vesln-tryc/index.js");require.alias("vesln-fload/lib/browser.js","hydro/deps/fload/lib/browser.js");require.alias("vesln-fload/lib/browser.js","hydro/deps/fload/index.js");require.alias("vesln-fload/lib/browser.js","fload/index.js");require.alias("vesln-fload/lib/browser.js","vesln-fload/index.js");require.alias("vesln-globalo/index.js","hydro/deps/globalo/index.js");require.alias("vesln-globalo/index.js","hydro/deps/globalo/index.js");require.alias("vesln-globalo/index.js","globalo/index.js");require.alias("vesln-globalo/index.js","vesln-globalo/index.js");require.alias("vesln-super/lib/super.js","hydro/deps/super/lib/super.js");require.alias("vesln-super/lib/super.js","hydro/deps/super/index.js");require.alias("vesln-super/lib/super.js","super/index.js");require.alias("vesln-super/lib/super.js","vesln-super/index.js");require.alias("hydro/lib/hydro.js","hydro/index.js");if(typeof exports=="object"){module.exports=require("hydro")}else if(typeof define=="function"&&define.amd){define(function(){return require("hydro")})}else{this["Hydro"]=require("hydro")}})(); | ||
(function(){function require(path,parent,orig){var resolved=require.resolve(path);if(null==resolved){orig=orig||path;parent=parent||"root";var err=new Error('Failed to require "'+orig+'" from "'+parent+'"');err.path=orig;err.parent=parent;err.require=true;throw err}var module=require.modules[resolved];if(!module._resolving&&!module.exports){var mod={};mod.exports={};mod.client=mod.component=true;module._resolving=true;module.call(this,mod.exports,require.relative(resolved),mod);delete module._resolving;module.exports=mod.exports}return module.exports}require.modules={};require.aliases={};require.resolve=function(path){if(path.charAt(0)==="/")path=path.slice(1);var paths=[path,path+".js",path+".json",path+"/index.js",path+"/index.json"];for(var i=0;i<paths.length;i++){var path=paths[i];if(require.modules.hasOwnProperty(path))return path;if(require.aliases.hasOwnProperty(path))return require.aliases[path]}};require.normalize=function(curr,path){var segs=[];if("."!=path.charAt(0))return path;curr=curr.split("/");path=path.split("/");for(var i=0;i<path.length;++i){if(".."==path[i]){curr.pop()}else if("."!=path[i]&&""!=path[i]){segs.push(path[i])}}return curr.concat(segs).join("/")};require.register=function(path,definition){require.modules[path]=definition};require.alias=function(from,to){if(!require.modules.hasOwnProperty(from)){throw new Error('Failed to alias "'+from+'", it does not exist')}require.aliases[to]=from};require.relative=function(parent){var p=require.normalize(parent,"..");function lastIndexOf(arr,obj){var i=arr.length;while(i--){if(arr[i]===obj)return i}return-1}function localRequire(path){var resolved=localRequire.resolve(path);return require(resolved,parent,path)}localRequire.resolve=function(path){var c=path.charAt(0);if("/"==c)return path.slice(1);if("."==c)return require.normalize(p,path);var segs=parent.split("/");var i=lastIndexOf(segs,"deps")+1;if(!i)i=0;path=segs.slice(0,i+1).join("/")+"/deps/"+path;return path};localRequire.exists=function(path){return require.modules.hasOwnProperty(localRequire.resolve(path))};return localRequire};require.register("hydrojs-loa/index.js",function(exports,require,module){var root=typeof global!=="undefined"?global:window;var toString=Object.prototype.toString;function is(type,input){if(type==="Object")return Object(input)===input;return toString.call(input)==="[object "+type+"]"}function str(input){if(!is("String",input))return;return root[input]||(root.require||require)(input)}function handeled(input){if(is("Object",input)||is("Function",input))return input}function raise(input){throw new TypeError("loa: Can't handle: "+input)}function loa(input){return handeled(input)||str(input)||raise(input)}module.exports=loa});require.register("vesln-evts/lib/evts.js",function(exports,require,module){var slice=Array.prototype.slice;function EventEmitter(){this.events={}}EventEmitter.prototype.on=function(evt,fn){this.events[evt]=this.events[evt]||[];this.events[evt].push(fn)};EventEmitter.prototype.emit=function(evt,fn){var listeners=this.events[evt];var i=0;var args=slice.call(arguments,1);var done=args.pop();if(!listeners)return done();(function next(err){if(err)return done(err);var handler=listeners[i];if(!handler)return done();i++;if(handler.length>args.length)return handler.apply(null,args.concat(next));try{handler.apply(null,args)}catch(e){return next(e)}next()})()};module.exports=EventEmitter});require.register("vesln-tryc/lib/browser.js",function(exports,require,module){module.exports=function(fn,end){var prev=window.onerror;function handler(err){window.onerror=prev;end(err)}window.onerror=function(msg,url,line){handler(new Error(msg+" at "+url+":"+line))};try{fn(handler)}catch(err){handler(err)}}});require.register("vesln-fload/lib/browser.js",function(exports,require,module){function load(files,callbacks){var target=document.getElementsByTagName("script")[0];files=files.slice(0);(function next(){var file=files.shift();if(!file)return callbacks.done();callbacks.pre(file,function(){var script=document.createElement("script");script.src=file;script.onload=script.onreadystatechange=function(e){if(e&&e.type==="load"||/loaded|complete/.test(script.readyState)){script.onload=null;script.onreadystatechange=null;callbacks.post(file,null,next)}};target.parentNode.insertBefore(script,target)})})()}module.exports=load});require.register("vesln-globalo/index.js",function(exports,require,module){module.exports=function(){if(typeof global!=="undefined"){return global}else if(typeof window!=="undefined"){return window}else if(typeof Alloy!=="undefined"&&typeof Alloy.Globals!=="undefined"){return Alloy.Globals}else if(typeof Ti!=="undefined"&&typeof Ti.App!=="undefined"){return Ti.App}}});require.register("vesln-super/lib/super.js",function(exports,require,module){var slice=Array.prototype.slice;var exports=module.exports=super_;function super_(){var args=slice.call(arguments);if(!args.length)return;if(typeof args[0]!=="function")return exports.merge(args);exports.inherits.apply(null,args)}exports.extend=function(proto,klass){var self=this,child=function(){return self.apply(this,arguments)};exports.merge([child,this]);exports.inherits(child,this);if(proto)exports.merge([child.prototype,proto]);if(klass)exports.merge([child,klass]);child.extend=this.extend;return child};exports.inherits=function(ctor,superCtor){ctor.super_=superCtor;if(Object.create){ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}else{ctor.prototype=new superCtor;ctor.prototype.constructor=ctor}};exports.merge=function(arr){var main=arr.length===2?arr.shift():{};var obj=null;for(var i=0,len=arr.length;i<len;i++){obj=arr[i];for(var p in obj){if(!obj.hasOwnProperty(p))continue;main[p]=obj[p]}}return main}});require.register("hydro/lib/hydro.js",function(exports,require,module){var EventEmitter=require("evts");var globalo=require("globalo");var loader=require("fload");var merge=require("super").merge;var loa=require("loa");var RootSuite=require("./hydro/suite/root");var Interface=require("./hydro/interface");var Suite=require("./hydro/suite");var Test=require("./hydro/test");var util=require("./hydro/util");function Hydro(){if(!(this instanceof Hydro))return new Hydro;this.loader=loader;this.plugins=[];this.options={plugins:[],aliases:{},globals:{},tests:[]};this.root=new RootSuite;this.emitter=new EventEmitter;this.interface=new Interface(this)}Hydro.prototype.set=function(key,val){if(Object(key)===key){this.options=merge([this.options,key])}else if(arguments.length===3){if(typeof this.options[key]==="undefined"){this.options[key]={}}this.options[key][val]=arguments[2]}else{this.options[key]=val}};Hydro.prototype.push=function(key,val){if(typeof this.options[key]==="undefined"){this.options[key]=[]}this.options[key].push(val)};Hydro.prototype.get=function(key){return this.options[key]};Hydro.prototype.on=function(evt,fn){this.emitter.on(evt,fn)};Hydro.prototype.suites=function(){var suites=[];this.traverse({enterSuite:function(suite){suites.push(suite)}});return suites};Hydro.prototype.tests=function(){var tests=[];this.traverse({test:function(test){tests.push(test)}});return tests};Hydro.prototype.traverse=function(handlers){handlers.test=handlers.test||util.noop;handlers.enterSuite=handlers.enterSuite||util.noop;handlers.leaveSuite=handlers.leaveSuite||util.noop;(function next(suite){handlers.enterSuite(suite);util.forEach(suite.suites,next);util.forEach(suite.tests,handlers.test);handlers.leaveSuite(suite)})(this.root)};Hydro.prototype.setup=function(){var emitter=this.emitter;var suite=null;var stackLimit=null;var self=this;this.loadPlugins();this.attachGlobals();this.attachProxies();this.loadFormatter();if(suite=this.get("suite")){this.interface.pushSuite(suite)}if(stackLimit=this.get("stackLimit")){Error.stackTraceLimit=stackLimit}this._init=true};Hydro.prototype.exec=function(fn){var emitter=this.emitter;var self=this;var suite=this.get("suite");fn=fn||function(){};this.loader(this.get("tests"),{pre:function(file,done){emitter.emit("pre:file",file,done)},post:function(file,contents,done){emitter.emit("post:file",file,done)},done:function(){if(suite)self.interface.popSuite();self.root.run(emitter,fn)}})};Hydro.prototype.run=function(fn){if(!this._init)this.setup();this.exec(fn)};Hydro.prototype.loadPlugins=function(){util.forEach(this.get("plugins"),function(plugin){plugin=loa(plugin);plugin(this,util);this.plugins.push(plugin)},this)};Hydro.prototype.createTest=function(){var test=Test.create(util.slice(arguments));var timeout=this.get("timeout");if(timeout)test.timeout(timeout);return test};Hydro.prototype.createSuite=function(title){return new Suite(title)};util.forEach(["addTest","addSuite"],function(method){Hydro.prototype[method]=function(){return this.interface[method].apply(this.interface,arguments)}});Hydro.prototype.attachGlobals=function(){var target=this.global();util.eachKey(this.get("globals"),function(key,val){target[key]=val})};Hydro.prototype.attachProxies=function(){var proxies=this.get("proxies");var target=this.global();var self=this;util.eachKey(proxies,function(key,val){target[key]=function(){return self.interface[val].apply(self.interface,arguments)}})};Hydro.prototype.global=function(){return this.get("attach")||globalo()};Hydro.prototype.loadFormatter=function(){var name=this.get("formatter");var formatter=null;if(!name)return;formatter=loa(name);if(util.isFunction(formatter))formatter=new formatter;formatter.use(this)};module.exports=Hydro;module.exports.util=util;module.exports.Test=Test;module.exports.Suite=Suite});require.register("hydro/lib/hydro/test/async.js",function(exports,require,module){var tryc=require("tryc");var sTimeout=setTimeout;var BaseTest=require("./base");var AsyncTest=BaseTest.extend();AsyncTest.prototype._timeout=1e3*2;AsyncTest.prototype.async=true;AsyncTest.prototype.exec=function(done){var timeout=null;var ended=false;var fn=this.fn;var context=this.context;function end(err){if(ended)return;ended=true;clearTimeout(timeout);done(err)}timeout=sTimeout(function(){end(new Error("Test timed out"))},this._timeout);tryc(function(done){fn.call(context,done)},end)};module.exports=AsyncTest});require.register("hydro/lib/hydro/test/base.js",function(exports,require,module){var extend=require("super").extend;var inherits=require("super");var Emitter=require("evts");var util=require("../util");var D=Date;function Base(title,fn,meta){this.title=title;this.fn=fn;this.meta=util.toArray(meta||[]);this.status=null;this.error=null;this.time=null;this.context={};this.events={pre:"pre:test",post:"post:test"};if(!this.fn)this.pending()}Base.extend=extend;inherits(Base,Emitter);Base.prototype.timeout=function(ms){this._timeout=ms;return this};Base.prototype.skip=function(condition){if(arguments.length&&!condition)return;this.status="skipped";this.time=0};Base.prototype.pending=function(){this.status="pending";this.time=0;return this};Base.prototype.fullTitle=function(){var parents=this.parents().splice(1);var fullTitle=[];for(var i=0,len=parents.length;i<len;i++){fullTitle.push(parents[i].title)}fullTitle.push(this.title);return fullTitle.join(" ")};Base.prototype.run=function(emitter,done){var self=this;var events=this.events;emitter.emit(events.pre,this,function(){var disabled=self.status==="pending"||self.status==="skipped";if(disabled)return emitter.emit(events.post,self,done);self.emit("before",function(err){if(err)return done(err);var start=(new D).getTime();self.exec(function(err){self.time=(new D).getTime()-start;if(err)self.fail(err);else self.pass();self.emit("after",function(err){if(err)return done(err);emitter.emit(events.post,self,done)})})})})};Base.prototype.parents=function(){return this.suite.parents().concat(this.suite)};Base.prototype.fail=function(err){this.status="failed";this.error=err;return this};Base.prototype.pass=function(){this.status="passed";return this};module.exports=Base});require.register("hydro/lib/hydro/test/index.js",function(exports,require,module){var SyncTest=require("./sync");var AsyncTest=require("./async");var BaseTest=require("./base");exports.create=function(params){var title=params.shift();var fn=null;var klass=null;if(typeof params[params.length-1]==="function")fn=params.pop();klass=fn&&fn.length?AsyncTest:SyncTest;return new klass(title,fn,params)};exports.SyncTest=SyncTest;exports.AsyncTest=AsyncTest;exports.BaseTest=BaseTest});require.register("hydro/lib/hydro/test/sync.js",function(exports,require,module){var BaseTest=require("./base");var SyncTest=BaseTest.extend();SyncTest.prototype.sync=true;SyncTest.prototype.exec=function(done){var err=null;try{this.fn.call(this.context)}catch(e){err=e}done(err)};module.exports=SyncTest});require.register("hydro/lib/hydro/suite/index.js",function(exports,require,module){var inherits=require("super");var Emitter=require("evts");var util=require("../util");function Suite(title){this.title=util.isFunction(title)?util.fnName(title):title;this.parent=null;this.tests=[];this.suites=[];this.events={pre:"pre:suite",post:"post:suite"}}inherits(Suite,Emitter);Suite.prototype.addTest=function(test){test.suite=this;this.tests.push(test)};Suite.prototype.addSuite=function(suite){suite.parent=this;this.suites.push(suite)};Suite.prototype.run=function(emitter,fn){var self=this;var runnable=this.tests.slice(0).concat(this.suites.slice(0));var current=null;var events=this.events;function next(err){if(err)return fn(err);if(current=runnable.shift()){return current.run(emitter,next)}self.emit("after",function(err){if(err)return fn(err);emitter.emit(events.post,self,fn)})}emitter.emit(events.pre,this,function(err){if(err)return fn(err);self.emit("before",next)})};Suite.prototype.parents=function(){return this.parent.parents().concat(this.parent)};module.exports=Suite});require.register("hydro/lib/hydro/suite/root.js",function(exports,require,module){var inherits=require("super");var Suite=require("./index");function RootSuite(){Suite.call(this);this.events={pre:"pre:all",post:"post:all"}}inherits(RootSuite,Suite);RootSuite.prototype.addTest=function(){throw new Error("Please add a test suite")};RootSuite.prototype.parents=function(){return[]};module.exports=RootSuite});require.register("hydro/lib/hydro/interface.js",function(exports,require,module){var Suite=require("./suite");var util=require("./util");function Interface(hydro){this.hydro=hydro;this.ctx=new Frame(hydro.root);this.stack=[this.ctx]}util.forEach(["createTest","createSuite"],function(method){Interface.prototype[method]=function(){return this.hydro[method].apply(this.hydro,arguments)}});Interface.prototype.addSuite=function(title,fn){var suite=this.pushSuite(title);if(fn)fn.call(suite);this.popSuite();return suite};Interface.prototype.pushSuite=function(title){var suite=!(title instanceof Suite)?this.hydro.createSuite.apply(this.hydro,arguments):title;this.ctx.suite.addSuite(suite);this.ctx=new Frame(suite);this.stack.push(this.ctx);return suite};Interface.prototype.popSuite=function(){this.ctx=this.stack[this.stack.length-2];return this.stack.pop()};Interface.prototype.addTest=function(){var test=this.hydro.createTest.apply(this.hydro,arguments);each("beforeEach",this,before);each("afterEach",this,after);util.forEach(this.ctx.beforeNext,before);this.ctx.beforeNext.length=0;util.forEach(this.ctx.afterNext,after);this.ctx.afterNext.length=0;this.ctx.suite.addTest(test);function before(fn){test.on("before",fn)}function after(fn){test.on("after",fn)}return test};Interface.prototype.beforeNext=function(fn){this.ctx.beforeNext.push(fn)};Interface.prototype.afterNext=function(fn){this.ctx.afterNext.push(fn)};Interface.prototype.before=function(fn){this.ctx.beforeEach.push(fn)};Interface.prototype.after=function(fn){this.ctx.afterEach.push(fn)};Interface.prototype.beforeAll=function(fn){this.ctx.suite.on("before",fn)};Interface.prototype.afterAll=function(fn){this.ctx.suite.on("after",fn)};function Frame(suite){this.suite=suite;this.beforeNext=[];this.beforeEach=[];this.afterEach=[];this.afterNext=[]}function each(key,interface,fn){var stack=interface.stack;for(var i=0,len=stack.length;i<len;i++){util.forEach(stack[i][key],fn)}}module.exports=Interface});require.register("hydro/lib/hydro/util.js",function(exports,require,module){var toString=Object.prototype.toString;var slice=Array.prototype.slice;exports.isString=function(str){return toString.call(str)==="[object String]"};exports.isFunction=function(fn){return toString.call(fn)==="[object Function]"};exports.isArray=function(arr){return toString.call(arr)==="[object Array]"};exports.slice=function(args){return slice.call(args)};exports.toArray=function(arr){if(exports.isArray(arr))return arr;return[arr]};exports.forEach=function(arr,fn,ctx){for(var i=0,len=arr.length;i<len;i++){fn.call(ctx,arr[i])}};exports.eachKey=function(obj,fn){for(var key in obj){if(!obj.hasOwnProperty(key))continue;fn(key,obj[key])}};exports.fnName=function(fn){if(fn.name)return fn.name;var match=/^\s?function ([^(]*)\(/.exec(fn);return match&&match[1]?match[1]:""};exports.noop=function(){}});require.alias("hydrojs-loa/index.js","hydro/deps/loa/index.js");require.alias("hydrojs-loa/index.js","hydro/deps/loa/index.js");require.alias("hydrojs-loa/index.js","loa/index.js");require.alias("hydrojs-loa/index.js","hydrojs-loa/index.js");require.alias("vesln-evts/lib/evts.js","hydro/deps/evts/lib/evts.js");require.alias("vesln-evts/lib/evts.js","hydro/deps/evts/index.js");require.alias("vesln-evts/lib/evts.js","evts/index.js");require.alias("vesln-evts/lib/evts.js","vesln-evts/index.js");require.alias("vesln-tryc/lib/browser.js","hydro/deps/tryc/lib/browser.js");require.alias("vesln-tryc/lib/browser.js","hydro/deps/tryc/index.js");require.alias("vesln-tryc/lib/browser.js","tryc/index.js");require.alias("vesln-tryc/lib/browser.js","vesln-tryc/index.js");require.alias("vesln-fload/lib/browser.js","hydro/deps/fload/lib/browser.js");require.alias("vesln-fload/lib/browser.js","hydro/deps/fload/index.js");require.alias("vesln-fload/lib/browser.js","fload/index.js");require.alias("vesln-fload/lib/browser.js","vesln-fload/index.js");require.alias("vesln-globalo/index.js","hydro/deps/globalo/index.js");require.alias("vesln-globalo/index.js","hydro/deps/globalo/index.js");require.alias("vesln-globalo/index.js","globalo/index.js");require.alias("vesln-globalo/index.js","vesln-globalo/index.js");require.alias("vesln-super/lib/super.js","hydro/deps/super/lib/super.js");require.alias("vesln-super/lib/super.js","hydro/deps/super/index.js");require.alias("vesln-super/lib/super.js","super/index.js");require.alias("vesln-super/lib/super.js","vesln-super/index.js");require.alias("hydro/lib/hydro.js","hydro/index.js");if(typeof exports=="object"){module.exports=require("hydro")}else if(typeof define=="function"&&define.amd){define(function(){return require("hydro")})}else{this["Hydro"]=require("hydro")}})(); |
@@ -12,2 +12,18 @@ /** | ||
var browsers = { | ||
'SL_Chrome': { | ||
base: 'SauceLabs', | ||
browserName: 'chrome' | ||
}, | ||
'SL_Firefox_26': { | ||
base: 'SauceLabs', | ||
browserName: 'firefox', | ||
platform: 'Windows XP', | ||
version: '26' | ||
}, | ||
'SL_Safari': { | ||
base: 'SauceLabs', | ||
browserName: 'safari', | ||
platform: 'OS X 10.9', | ||
version: '7' | ||
}, | ||
'SL_IE_8': { | ||
@@ -14,0 +30,0 @@ base: 'SauceLabs', |
@@ -197,3 +197,3 @@ /** | ||
fn = fn || function(){}; | ||
fn = fn || util.rethrow; | ||
@@ -200,0 +200,0 @@ this.loader(this.get('tests'), { |
@@ -106,2 +106,15 @@ /** | ||
/** | ||
* Return the suites full title | ||
* | ||
* @return {String} | ||
* @api public | ||
*/ | ||
Suite.prototype.fullTitle = function() { | ||
var base = this.parent.fullTitle(); | ||
if (base) base += ' '; | ||
return base + this.title; | ||
}; | ||
/** | ||
* Primary export. | ||
@@ -108,0 +121,0 @@ */ |
@@ -56,2 +56,13 @@ /** | ||
/** | ||
* The root suite has an empty title | ||
* | ||
* @returns {String} | ||
* @api public | ||
*/ | ||
RootSuite.prototype.fullTitle = function() { | ||
return ''; | ||
}; | ||
/** | ||
* Primary export. | ||
@@ -58,0 +69,0 @@ */ |
@@ -97,2 +97,14 @@ /** | ||
/** | ||
* Return the titles of all parent suites + | ||
* the test title. | ||
* | ||
* @returns {String} | ||
* @api public | ||
*/ | ||
Base.prototype.fullTitle = function() { | ||
return this.suite.fullTitle() + ' ' + this.title; | ||
}; | ||
/** | ||
* Run the test. | ||
@@ -109,3 +121,4 @@ * | ||
emitter.emit(events.pre, this, function() { | ||
emitter.emit(events.pre, this, function(err) { | ||
if (err) return done(err); | ||
var disabled = self.status === 'pending' || self.status === 'skipped'; | ||
@@ -112,0 +125,0 @@ if (disabled) return emitter.emit(events.post, self, done); |
@@ -7,2 +7,3 @@ /** | ||
var AsyncTest = require('./async'); | ||
var BaseTest = require('./base'); | ||
@@ -37,1 +38,7 @@ /** | ||
exports.AsyncTest = AsyncTest; | ||
/** | ||
* Export `BaseTest`. | ||
*/ | ||
exports.BaseTest = BaseTest; |
@@ -125,1 +125,12 @@ /** | ||
exports.noop = function(){}; | ||
/** | ||
* a callback which ensures users hear about errors | ||
* | ||
* @param {Error} err | ||
* @api public | ||
*/ | ||
exports.rethrow = function(err) { | ||
if (err) setTimeout(function(){ throw err; }, 0); | ||
}; |
{ | ||
"name": "hydro", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"preferGlobal": true, | ||
@@ -24,3 +24,3 @@ "description": "Teeny-weeny test runner for Node.js", | ||
"evts": "0.1.0", | ||
"tryc": "~0.0.5", | ||
"tryc": "~0.1.0", | ||
"fload": "*", | ||
@@ -42,3 +42,3 @@ "loa": "0.0.2", | ||
"uglify-js": "*", | ||
"karma": "~0.10.8", | ||
"karma": "0.11.12", | ||
"karma-chrome-launcher": "~0.1.1", | ||
@@ -48,3 +48,3 @@ "karma-firefox-launcher": "~0.1.2", | ||
"karma-safari-launcher": "~0.1.1", | ||
"karma-sauce-launcher": "~0.1.8", | ||
"karma-sauce-launcher": "0.2.0", | ||
"karma-hydro": "*", | ||
@@ -51,0 +51,0 @@ "hydro-karma-adapter": "*", |
@@ -9,2 +9,45 @@ [![NPM | ||
## Quick start guide | ||
1. Install `hydro` and any plugins you might want to use with NPM. | ||
(Suggestions: install a basic test reporter, like | ||
[`hydro-bdd`](https://github.com/hydrojs/hydro-bdd) or | ||
[`hydro-tdd`](https://github.com/hydrojs/hydro-tdd).) | ||
```bash | ||
npm install --save-dev hydro hydro-bdd | ||
``` | ||
2. Create a `hydro.conf.js` file in the root of your project. | ||
```javascript | ||
var assert = require('assert'); | ||
module.exports = function(hydro) { | ||
hydro.set({ | ||
attach: global, | ||
suite: 'My test suite', | ||
formatter: 'hydro-simple', | ||
plugins: ['hydro-bdd'], | ||
tests: ['./test/*.js'], | ||
globals: { assert: assert } | ||
}); | ||
} | ||
``` | ||
3. Write some tests in the directory you pointed to. | ||
```javascript | ||
describe('A basic test', function() { | ||
it('should allow for assertions', function() { | ||
assert(true); | ||
}); | ||
}); | ||
``` | ||
4. Now run your test from the root directory of your project! | ||
```bash | ||
./node_modules/.bin/hydro | ||
``` | ||
## Authors | ||
@@ -11,0 +54,0 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
981403
2806
61
+ Addedtryc@0.1.0(transitive)
- Removedtryc@0.0.5(transitive)
Updatedtryc@~0.1.0