Socket
Socket
Sign inDemoInstall

jasmine-dom

Package Overview
Dependencies
53
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.6 to 0.3.0

examples/lib/jasmine/jasmine-html.js

252

lib/jasmine-dom/index.js
var fs = require('fs'),
path = require('path');
path = require('path');
function JasmineRunner(options, callback){
var doServer = options.serve,
port = options.port || 8081,
refreshInterval = options.refreshInterval || 2000,
runners = options.runners || null,
that = this;
var doServer = options.serve,
port = options.port || 8081,
refreshInterval = options.refreshInterval || 2000,
runners = options.runners || null,
routeConsole = options.routeConsole,
that = this;
this.isRunningTests = false;
this.isTestRunQueued = false;
this.isRunningTests = false;
this.isTestRunQueued = false;
this.reporter = this._setupReporter(function(){
this.reporter = this._setupReporter(function(){
callback();
callback();
}); // async
}); // async
if(doServer){
this.server = that._setupServer({
port: port,
reporter: this.reporter,
refreshInterval: refreshInterval
});
if(doServer){
this.server = that._setupServer({
port: port,
reporter: this.reporter,
refreshInterval: refreshInterval
});
};
}
if(runners){
this.tests = this._setupRunners({
runners: runners,
jasmineReporter: this.reporter.getJasmineReporter(),
});
} else {
console.error("I don't have any tests to run!");
process.exit(1);
}
};
if(runners){
this.tests = this._setupRunners({
runners: runners,
jasmineReporter: this.reporter.getJasmineReporter(),
routeConsole: routeConsole
});
} else {
console.error("I don't have any tests to run!");
process.exit(1);
}
}
JasmineRunner.prototype._setupReporter = function(callback){
console.debug("Setting up reporter");
console.debug("Setting up reporter");
var reporter = require('./reporter-agregator.js').create({
onDone: function(){
console.debug("Reporter created.");
callback();
}
});
var reporter = require('./reporter-agregator.js').create({
onDone: function(){
console.debug("Reporter created.");
callback();
}
});
return reporter;
return reporter;

@@ -56,44 +58,46 @@ };

JasmineRunner.prototype._setupServer = function(options){
console.debug("Setting up server");
var that = this,
server = require('./server.js');
console.debug("Setting up server");
var that = this,
server = require('./server.js');
server.start(options.port, function(){
callback(server);
});
server.start(options.port, function(){
callback(server);
});
options.reporter.onUpdate(function(report){
server.updateHtml(report.html);
server.updateJson(report.simple);
options.reporter.onUpdate(function(report){
server.updateHtml(report.html);
server.updateJson(report.simple);
console.debug("Tests will run again in " + (options.refreshInterval/1000) + " seconds.");
setTimeout(function(){
that.runTests();
}, options.refreshInterval);
});
console.debug("Tests will run again in " + (options.refreshInterval/1000) + " seconds.");
setTimeout(function(){
that.runTests();
}, options.refreshInterval);
});
return server;
return server;
};
JasmineRunner.prototype._setupRunners = function(options,callback){
console.debug("Setting up tests.");
console.debug("Setting up tests.");
var tests = [];
var runners = options.runners || [],
jasmineReporter = options.jasmineReporter;
var tests = [];
var runners = options.runners || [],
jasmineReporter = options.jasmineReporter,
routeConsole = options.routeConsole;
for(var k in runners){
var runner = runners[k];
console.debug('Creating test based on ' + runner);
for(var k in runners){
var runner = runners[k];
console.debug('Creating test based on ' + runner);
var test = require('./runner-from-html.js').create({
runner: runner,
jasmineReporter: jasmineReporter
});
tests.push(test);
}
var test = require('./runner-from-html.js').create({
runner: runner,
jasmineReporter: jasmineReporter,
routeConsole: routeConsole
});
tests.push(test);
}
console.debug("Finished creating tests ( based on " +tests.length + " runner/s).");
console.debug("Finished creating tests ( based on " +tests.length + " runner/s).");
return tests;
return tests;
};

@@ -103,74 +107,74 @@

var that = this;
var that = this;
// We have to maintain synchronisity, otherwise things
// get hectic.
if(this.isRunningTests) {
// DANGER: if more than one call to runTests is made when
// tests are running, only the last callback will ever be
// triggered.
this.isTestRunQueued = true;
this.queuedCallback = callback;
console.debug("Cannot run tests concurrently. Queued another run.");
return;
};
var whenAllTestsHaveRun = function(){
console.debug("Finished running tests.");
// We have to maintain synchronisity, otherwise things
// get hectic.
if(this.isRunningTests) {
// DANGER: if more than one call to runTests is made when
// tests are running, only the last callback will ever be
// triggered.
this.isTestRunQueued = true;
this.queuedCallback = callback;
console.debug("Cannot run tests concurrently. Queued another run.");
return;
}
var whenAllTestsHaveRun = function(){
console.debug("Finished running tests.");
if(callback) callback(that.reporter.getReport());
that.reporter.reset();
if(callback) callback(that.reporter.getReport());
that.reporter.reset();
that.isRunningTests = false;
if(that.isTestRunQueued){
that.isTestRunQueued = false;
that.runTests(that.queuedCallback);
that.queuedCallback = false;
}
};
that.isRunningTests = false;
if(that.isTestRunQueued){
that.isTestRunQueued = false;
that.runTests(that.queuedCallback);
that.queuedCallback = false;
}
};
console.debug("Running tests.");
this.isRunningTests = true;
console.debug("Running tests.");
this.isRunningTests = true;
var queue = [],
tests = this.tests;
for(var i = 0; i < tests.length; i++) queue.push(tests[i]);
var queue = [],
tests = this.tests;
for(var i = 0; i < tests.length; i++) queue.push(tests[i]);
// !! Is recursive
var runNextTest = function(){
if(queue.length == 0){
whenAllTestsHaveRun();
return;
}
// !! Is recursive
var runNextTest = function(){
if(queue.length === 0){
whenAllTestsHaveRun();
return;
}
var test = queue.pop();
console.debug("Running " + test.name);
test.run(function(){
console.debug("Finished running " + test.name);
runNextTest();
});
};
var test = queue.pop();
console.debug("Running " + test.name);
test.run(function(){
console.debug("Finished running " + test.name);
runNextTest();
});
};
runNextTest();
runNextTest();
};
exports.run = function(options, callback){
var onDone = options.onDone || function(){},
debug = options.debug;
var onDone = options.onDone || function(){},
debug = options.debug;
console.debug = debug ? function(msg){ console.log(msg); } : function(msg){};
console.debug = debug ? function(msg){ console.log(msg); } : function(msg){};
process.on('uncaughtException', function(err){
if(debug){
console.debug("An uncaught error occured!");
console.error(err.message + "\n",err.stack);
} else {
console.error("An error occurred while running the tests. Use the --debug switch to find out more.")
exit(1);
}
});
process.on('uncaughtException', function(err){
if(debug){
console.debug("An uncaught error occured!");
console.error(err.message + "\n",err.stack);
} else {
console.error("An error occurred while running the tests. Use the --debug switch to find out more.");
exit(1);
}
});
var runner = new JasmineRunner(options, function(){
runner.runTests(onDone);
callback( runner );
});
var runner = new JasmineRunner(options, function(){
runner.runTests(onDone);
callback( runner );
});
};

@@ -21,2 +21,3 @@ var path = require('path');

this._jasmineReporters['simpleReporter'] = require('./reporter-simple').create();
this._jasmineReporters['detailedReporter'] = require('./reporter-detailed').create();
this._jasmineReporters['junitReporter'] = require('./reporter-junit').create();

@@ -23,0 +24,0 @@ this._jasmineReporters['htmlReporter'] = require('./reporter-html').create({

@@ -23,3 +23,3 @@ var cp = function(o){ if(typeof o != 'object') return o; var n = {}; for(var k in o) n[k] = o[k]; return n; };

this.results[this.currentSet].name = name;
}
};

@@ -41,3 +41,3 @@ SimpleReporter.prototype.reportSpecResults = function(spec){

}
}
};

@@ -52,3 +52,3 @@ SimpleReporter.prototype.reportRunnerResults = function(runner){

this.currentSet++;
}
};

@@ -94,2 +94,2 @@ SimpleReporter.prototype.updateReport = function(){

return new SimpleReporter(opt);
}
};

@@ -17,3 +17,4 @@ function Runner( options ){

path: require('path').normalize(path),
name: name
name: name,
routeConsole: options.routeConsole
};

@@ -31,3 +32,3 @@ };

console.debug(errors);
exit(1);
process.exit(1);
}

@@ -56,2 +57,13 @@

var displayedHeader = false;
var displayLog = this._options.routeConsole;
var log = function(type, msg){
if(! displayLog ) return;
if(! displayedHeader){
console.log('=== console messages for ' + pathToHtml + ' ===')
displayedHeader = true;
}
console.log(type + ' - ' + msg);
};
require('jsdom').env({

@@ -61,2 +73,8 @@ html: pathToHtml,

done: function(errors,window){
window.console.log = function(msg){ log( 'LOG ', msg); };
window.console.error = function(msg){ log( 'ERROR', msg); };
window.console.warn = function(msg){ log( 'WARN ', msg); };
window.console.info = function(msg){ log( 'INFO ', msg); };
if(errors){

@@ -63,0 +81,0 @@ console.error('Error when constructing DOM for runner.');

{
"name" : "jasmine-dom"
, "version" : "0.2.6"
, "version" : "0.3.0"

@@ -14,3 +14,3 @@ , "description" : "Run your jasmine html SpecRunner in node.js."

, "engines" : { "node" : ">= 0.4.9" }
, "dependencies": { "jsdom" : "0.2.1",
, "dependencies": { "jsdom" : "0.2.10",
"node-static" : "0.5.7",

@@ -17,0 +17,0 @@ "yaml" : "0.2.1",

@@ -27,3 +27,3 @@ node-jasmine-dom

* <code>--help</code>, provides usage information
* <code>--format simple|nice|json|html|junit</code>, displays the result in the specified format
* <code>--format simple|detailed|nice|json|html|junit</code>, displays the result in the specified format
* <code>--output path</code>, writes the output to the specified file

@@ -34,2 +34,3 @@ * <code>--server [port]</code>, serves a simple (but effective) page showing the current state

the tests (because the server is constantly running 'em).
* <code>--routeconsole</code>, calls to window.console.log (or error, warn, info) will be displayed in the console

@@ -36,0 +37,0 @@ server

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