test-agent
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -0,1 +1,16 @@ | ||
# 0.2.0 | ||
- TestAgent.Responder now has .once (per event emitter spec) | ||
- Fixed XUnit reporter support | ||
- Added event mirroring support you can now send a message | ||
to the server and all events of those types will be forwarded or | ||
mirrored to your client websocket. | ||
- Added base node/client as a building block for new commands | ||
- improved test-agent test. It now offers an option of reporters and | ||
will show reports in stdout with correct exit status on | ||
error/success. | ||
# 0.1.2 | ||
- calling require on cached script url will now | ||
correctly fire after (or if) the script has been loaded. | ||
# 0.1.1 | ||
@@ -2,0 +17,0 @@ |
@@ -85,2 +85,3 @@ var server = new (require('../websocket-server')), | ||
use(Enhancements.QueueTests). | ||
use(Enhancements.EventMirror). | ||
use(Enhancements.Watcher); | ||
@@ -87,0 +88,0 @@ |
@@ -1,6 +0,9 @@ | ||
var Client = require(__dirname + '/../../test-agent/websocket-client').TestAgent.WebsocketClient, | ||
var Client = require('../../node/client'), | ||
Apps = require('../../node/server'), | ||
url = 'ws://localhost:8789', | ||
optimist = require('optimist'), | ||
argv, | ||
instance = new Client({ | ||
reporters, | ||
reporterList, | ||
client = new Client({ | ||
url: url, | ||
@@ -10,6 +13,29 @@ retry: true | ||
argv = optimist | ||
.usage('Executes tests in all available clients. Defaults to running all tests.\n\njs-test-agent test [file, ...]') | ||
.argv; | ||
reporters = require('mocha').reporters; | ||
function reporterList(){ | ||
var base, | ||
list; | ||
list = Object.keys(reporters); | ||
base = list.indexOf('Base'); | ||
if(base !== -1){ | ||
list.splice(base, 1); | ||
} | ||
return list.join(', '); | ||
} | ||
argv = optimist. | ||
usage([ | ||
'Executes tests in all available clients. ', | ||
'Defaults to running all tests.\n\n', | ||
'js-test-agent test [file, ...]' | ||
].join('')). | ||
option('reporter', { | ||
desc: 'Mocha reporters available: [' + reporterList() + ']', | ||
default: 'Spec' | ||
}). | ||
argv; | ||
if (argv.help) { | ||
@@ -20,4 +46,10 @@ optimist.showHelp(); | ||
instance.on('open', function(socket) { | ||
var files = process.argv.slice(3), | ||
if(!reporters[argv.reporter]){ | ||
console.error('ERROR: Invalid Reporter\n'); | ||
optimist.showHelp(); | ||
process.exit(1); | ||
} | ||
client.on('open', function(socket) { | ||
var files = argv._.slice(1), | ||
fsPath = require('path'); | ||
@@ -33,6 +65,19 @@ | ||
instance.send('queue tests', {files: files}); | ||
process.exit(0); | ||
client.mirrorServerEvents(['error', 'test data'], true); | ||
client.send('queue tests', {files: files}); | ||
}); | ||
instance.start(); | ||
client.use(Apps.MochaTestEvents, { | ||
reporterClass: reporters[argv.reporter] | ||
}); | ||
client.on('test runner end', function(runner){ | ||
var reporter = runner.getMochaReporter(); | ||
client.send('close'); | ||
if(reporter.failures == 0){ | ||
process.exit(0); | ||
} | ||
process.exit(1); | ||
}); | ||
client.start(); |
@@ -30,8 +30,24 @@ var Proxy = require(__dirname + '/runner-stream-proxy'), | ||
Reporter.prototype.createRunner = function createRunner() { | ||
var self = this; | ||
this.runner = new Responder(); | ||
this.reporter = new this.reporterClass(this.runner); | ||
this.proxy = new Proxy(this.runner); | ||
this.runner.on('end', function(){ | ||
self.emit('end', self); | ||
}); | ||
}; | ||
/** | ||
* Returns the mocha reporter used in the proxy. | ||
* | ||
* | ||
* @return {Object} mocha reporter. | ||
*/ | ||
Reporter.prototype.getMochaReporter = function getMochaReporter(){ | ||
return this.reporter; | ||
}; | ||
/** | ||
* Reponds to a an event in the form of a json string or an array. | ||
@@ -52,5 +68,2 @@ * This is passed through to the proxy which will format the results | ||
} | ||
if(data.event === 'end'){ | ||
this.emit('end', this); | ||
} | ||
return this.proxy.respond([data.event, data.data]); | ||
@@ -57,0 +70,0 @@ }; |
@@ -22,2 +22,6 @@ var Responder = require(__dirname + '/../../test-agent/responder').TestAgent.Responder; | ||
copy.call(this, suite); | ||
this._fullTitle = this.fullTitle; | ||
this.fullTitle = function(){ | ||
return suite.fullTitle; | ||
} | ||
}; | ||
@@ -24,0 +28,0 @@ |
@@ -8,3 +8,4 @@ module.exports = exports = { | ||
QueueTests: require(__dirname + '/queue-tests'), | ||
EventMirror: require(__dirname + '/event-mirror'), | ||
Suite: require(__dirname + '/suite') | ||
}; |
@@ -107,2 +107,3 @@ var Reporter = require(__dirname + '/../mocha/reporter'); | ||
this.reporter.respond(['suite', baseEvent]); | ||
this.reporter.respond(['test', baseEvent]); | ||
@@ -113,11 +114,15 @@ this.reporter.respond(['fail', merge(baseEvent, { | ||
})]); | ||
this.reporter.respond(['test end', merge(baseEvent, { | ||
state: 'failed' | ||
})]); | ||
this.reporter.respond(['suite end', baseEvent]); | ||
}, | ||
_onRunnerEnd: function _onRunnerEnd(server, runner) { | ||
var endArgs = Array.prototype.slice.call(arguments).slice(1); | ||
endArgs.unshift('test runner end'); | ||
this.isRunning = false; | ||
this.savedError = undefined; | ||
server.emit.apply(server, endArgs); | ||
}, | ||
@@ -124,0 +129,0 @@ |
@@ -36,3 +36,3 @@ var ws = require('websocket.io'), | ||
* //second argument passed to constructor | ||
* server.enhance(Enhancement, {isBlue: true}); | ||
* server.use(Enhancement, {isBlue: true}); | ||
* | ||
@@ -39,0 +39,0 @@ * |
@@ -89,3 +89,3 @@ (function(exports) { | ||
* @param {String} type event name. | ||
* @param {String} callback event callback. | ||
* @param {Function} callback event callback. | ||
*/ | ||
@@ -115,2 +115,23 @@ addEventListener: function addEventListener(type, callback) { | ||
/** | ||
* Adds an event listener which will | ||
* only fire once and then remove itself. | ||
* | ||
* | ||
* @param {String} type event name. | ||
* @param {Function} callback fired when event is emitted. | ||
*/ | ||
once: function once(type, callback) { | ||
var self = this; | ||
//console.log(callback.toString()); | ||
function onceCb() { | ||
callback.apply(this, arguments); | ||
self.removeEventListener(type, onceCb); | ||
} | ||
this.addEventListener(type, onceCb); | ||
return this; | ||
}, | ||
/** | ||
* Emits an event. | ||
@@ -117,0 +138,0 @@ * |
{ | ||
"name": "test-agent", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"author": "James Lal", | ||
@@ -29,2 +29,3 @@ "description": "execute client side tests from browser report back to cli", | ||
"ws": "~0.4", | ||
"debug": "~0.6", | ||
"match-files": "~0.1.1", | ||
@@ -31,0 +32,0 @@ "node-static": "~0.5" |
@@ -473,3 +473,3 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
* @param {String} type event name. | ||
* @param {String} callback event callback. | ||
* @param {Function} callback event callback. | ||
*/ | ||
@@ -499,2 +499,23 @@ addEventListener: function addEventListener(type, callback) { | ||
/** | ||
* Adds an event listener which will | ||
* only fire once and then remove itself. | ||
* | ||
* | ||
* @param {String} type event name. | ||
* @param {Function} callback fired when event is emitted. | ||
*/ | ||
once: function once(type, callback) { | ||
var self = this; | ||
//console.log(callback.toString()); | ||
function onceCb() { | ||
callback.apply(this, arguments); | ||
self.removeEventListener(type, onceCb); | ||
} | ||
this.addEventListener(type, onceCb); | ||
return this; | ||
}, | ||
/** | ||
* Emits an event. | ||
@@ -501,0 +522,0 @@ * |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
447314
114
15113
8
+ Addeddebug@~0.6
+ Addeddebug@0.6.0(transitive)
- Removeddebug@4.4.0(transitive)
- Removedms@2.1.3(transitive)