test-agent
Advanced tools
Comparing version 0.23.7 to 0.23.8
@@ -129,8 +129,2 @@ var Client = require('../../node/client'), | ||
client.on('error', function (error) { | ||
console.error(error.msg); | ||
client.send('close'); | ||
process.exit(1); | ||
}) | ||
client.on('test runner end', function(runner){ | ||
@@ -137,0 +131,0 @@ var reporter = runner.getMochaReporter(); |
@@ -95,5 +95,3 @@ (function(window) { | ||
createIframe: function(src) { | ||
var iframe = document.createElement('iframe'), | ||
iframeError; | ||
var iframe = document.createElement('iframe'); | ||
iframe.src = src + '?time' + String(Date.now()); | ||
@@ -113,14 +111,2 @@ | ||
iframe.addEventListener('load', function() { | ||
clearTimeout(iframeError); | ||
}); | ||
iframeError = setTimeout(function() { | ||
var error = 'Cannot access ' + new URL(src).hostname; | ||
console.error('Error loading ' + src); | ||
this.worker.send('error', { msg: error }); | ||
this._running = false; | ||
}.bind(this), 1000); | ||
document.body.appendChild(iframe); | ||
@@ -127,0 +113,0 @@ |
@@ -13,4 +13,3 @@ (function(window) { | ||
var Base = TestAgent.Mocha.ReporterBase, | ||
exports = window.TestAgent.Mocha, | ||
log = console.log.bind(console); | ||
exports = window.TestAgent.Mocha; | ||
@@ -32,25 +31,9 @@ MochaReporter.console = window.console; | ||
MochaReporter.console.log = function consoleLogShim() { | ||
var args = Array.prototype.slice.call(arguments), | ||
message = TestAgent.format.apply(TestAgent, arguments); | ||
//real console log | ||
log.apply(this, arguments); | ||
function consoleShim(type) { | ||
var args = Array.prototype.slice.call(arguments, 1), | ||
messages = args, | ||
stack = new Error().stack; | ||
//for server | ||
var stack, messages = args.map(function(item) { | ||
if (!item) { | ||
return item; | ||
} | ||
return (item.toString) ? item.toString() : item; | ||
}); | ||
try { | ||
throw new Error(); | ||
} catch (e) { | ||
stack = e.stack; | ||
} | ||
if (stack) { | ||
//re-orgnaize the stack to exlude the above | ||
// Re-organize the stack to exlude the above | ||
stack = stack.split('\n').map(function(e) { | ||
@@ -64,5 +47,8 @@ return e.trim().replace(/^at /, ''); | ||
//this is temp | ||
var logDetails = {messages: [message], stack: stack }; | ||
if (type === 'trace') { | ||
messages = [stack]; | ||
type = 'log'; | ||
} | ||
var logDetails = { messages: messages, stack: stack }; | ||
@@ -74,6 +60,14 @@ if (MochaReporter.testAgentEnvId) { | ||
MochaReporter.send( | ||
JSON.stringify(['log', logDetails]) | ||
JSON.stringify([type, logDetails]) | ||
); | ||
}; | ||
MochaReporter.console.log = consoleShim.bind(null, 'log'); | ||
MochaReporter.console.debug = consoleShim.bind(null, 'log'); | ||
MochaReporter.console.info = consoleShim.bind(null, 'info'); | ||
MochaReporter.console.warn = consoleShim.bind(null, 'warn'); | ||
MochaReporter.console.error = consoleShim.bind(null, 'error'); | ||
MochaReporter.console.dir = consoleShim.bind(null, 'dir'); | ||
MochaReporter.console.trace = consoleShim.bind(null, 'trace'); | ||
runner.on('suite', function onSuite(suite) { | ||
@@ -80,0 +74,0 @@ indentation++; |
@@ -93,4 +93,24 @@ (function() { | ||
if (!this.coverage) { | ||
this.on('log', function onLog(data) { | ||
console.log.apply(console, data.messages); | ||
this.on({ | ||
'log': function onLog(data) { | ||
console.log.apply(console, data.messages); | ||
}, | ||
'info': function onInfo(data) { | ||
console.info.apply(console, data.messages); | ||
}, | ||
'warn': function onWarn(data) { | ||
console.warn.apply(console, data.messages); | ||
}, | ||
'error': function onError(data) { | ||
console.error.apply(console, data.messages); | ||
}, | ||
'dir': function onDir(data) { | ||
console.dir.apply(console, data.messages); | ||
} | ||
}); | ||
@@ -97,0 +117,0 @@ } |
{ | ||
"name": "test-agent", | ||
"version": "0.23.7", | ||
"version": "0.23.8", | ||
"author": "James Lal", | ||
@@ -5,0 +5,0 @@ "description": "execute client side tests from browser report back to cli", |
Sorry, the diff of this file is too big to display
252477
7862