test-agent
Advanced tools
Comparing version 0.22.13 to 0.22.14
@@ -34,2 +34,7 @@ var server = new (require('../websocket-server')), | ||
option('coverage-thresholds', { | ||
alias: 't', | ||
desc: "Path to coverage thresholds files" | ||
}). | ||
option('growl', { | ||
@@ -91,7 +96,9 @@ desc: "Enables growl notifications for server" | ||
use(Enhancements.MochaTestEvents). | ||
use(Enhancements.BlanketConsoleReporter). | ||
use(Enhancements.QueueTests). | ||
use(Enhancements.StartCoverages). | ||
use(Enhancements.EventMirror). | ||
use(Enhancements.Watcher); | ||
use(Enhancements.Watcher). | ||
use(Enhancements.BlanketConsoleReporter, { | ||
path: fsPath.join(process.env.PWD, argv['coverage-thresholds']) | ||
}); | ||
@@ -98,0 +105,0 @@ if(argv.growl){ |
var Client = require('../../node/client'), | ||
Apps = require('../../node/server'), | ||
optimist = require('optimist'), | ||
fsPath = require('path'), | ||
argv, | ||
@@ -53,2 +54,6 @@ reporters, | ||
}). | ||
option('coverage-thresholds', { | ||
alias: 't', | ||
desc: "Path to coverage thresholds files" | ||
}). | ||
option('server', { | ||
@@ -118,3 +123,5 @@ desc: 'Location of the websocket server to connect to.', | ||
if (enableCoverage) { | ||
client.use(Apps.BlanketConsoleReporter); | ||
client.use(Apps.BlanketConsoleReporter, { | ||
path: fsPath.join(process.env.PWD, argv['coverage-thresholds']) | ||
}); | ||
} | ||
@@ -131,8 +138,2 @@ | ||
client.on('error', function (error) { | ||
console.error(error.msg); | ||
client.send('close'); | ||
process.exit(1); | ||
}) | ||
client.on('test runner end', function(runner){ | ||
@@ -139,0 +140,0 @@ var reporter = runner.getMochaReporter(); |
(function() { | ||
'use strict'; | ||
function BlanketConsoleReporter() { | ||
function BlanketConsoleReporter(options) { | ||
for (var key in options) { | ||
if (options.hasOwnProperty(key)) { | ||
this[key] = options[key]; | ||
} | ||
} | ||
this.setupThresholds(); | ||
this.totalPasses = 0; | ||
this.totalFailures = 0; | ||
} | ||
@@ -12,2 +20,3 @@ | ||
server.on('coverage report', this._onCoverageData.bind(this)); | ||
server.on('test runner end', this._printCoverageSummary.bind(this)); | ||
}, | ||
@@ -30,3 +39,3 @@ | ||
var percentage = function(covered, total) { | ||
return (Math.round(((covered / total) * 100) * 100) / 100) + ' %'; | ||
return Math.round(((covered / total) * 100) * 100) / 100; | ||
}; | ||
@@ -72,14 +81,19 @@ | ||
_printConsoleFormat: function _printConsoleFormat(coverResults) { | ||
var titleColor = '\u001b[1;36m', | ||
var appName = coverResults[0].filename.match(/[A-Za-z0-9_-]+/gi)[1], | ||
titleColor = '\u001b[1;36m', | ||
fileNameColor = '\u001b[0;37m', | ||
stmtColor = '\u001b[0;33m', | ||
percentageColor = '\u001b[0;36m', | ||
passColor = '\u001b[0;32m', | ||
failColor = '\u001b[0;31m', | ||
thresholdColor = '\u001b[0;34m', | ||
originColor = '\u001b[0m', | ||
outputFormat; | ||
outputFormat, | ||
fails = 0, | ||
totals = coverResults.length - 1; | ||
// Print title | ||
console.log('\n%s-- Blanket.js Test Coverage Result --\n', titleColor); | ||
console.log('%sFile Name%s - %sCovered/Total Smts%s - %sCoverage(%)%s\n', | ||
fileNameColor, originColor, stmtColor, originColor, percentageColor, | ||
originColor); | ||
console.log('\n%s-- Test Coverage for %s%s%s --\n', titleColor, stmtColor, | ||
(appName[0].toUpperCase() + appName.slice(1)), titleColor); | ||
console.log('%sFile Name%s - %sCovered/Total Smts%s - %sCoverage (%)\n', | ||
fileNameColor, originColor, stmtColor, originColor, passColor); | ||
@@ -90,4 +104,16 @@ // Print coverage result for each file | ||
formatPrefix = (filename === 'Global Total' ? '\n' : ' '), | ||
seperator = ' - '; | ||
seperator = ' - ', | ||
isPassThreshold = this.validateThreshold(appName, dataItem), | ||
arrow = isPassThreshold ? ' > ' : ' < ', | ||
covColor = isPassThreshold ? passColor : failColor; | ||
if (filename !== 'Global Total') { | ||
if (!isPassThreshold) { | ||
fails++; | ||
this.totalFailures++; | ||
} else { | ||
this.totalPasses++; | ||
} | ||
} | ||
filename = (filename === 'Global Total' ? filename : | ||
@@ -98,7 +124,56 @@ (filename.substr(0, filename.indexOf('?')) || filename)); | ||
outputFormat += stmtColor + dataItem.stmts + originColor + seperator; | ||
outputFormat += percentageColor + dataItem.percentage + originColor; | ||
outputFormat += covColor + dataItem.percentage + ' %' + originColor; | ||
console.log(outputFormat); | ||
}); | ||
}, this); | ||
outputFormat = thresholdColor + '\nThreshold=' + | ||
this.getAppThreshold(appName) + '%, '; | ||
if (fails === 0) { | ||
outputFormat += passColor + 'COVERAGE PASS'; | ||
} else { | ||
outputFormat += failColor + 'COVERAGE FAIL: ' + fails + '/' + | ||
totals + ' files failed coverage'; | ||
} | ||
console.log(outputFormat); | ||
}, | ||
_printCoverageSummary: function _printCoverageSummary() { | ||
var passColor = '\u001b[0;32m', | ||
failColor = '\u001b[0;31m', | ||
originColor = '\u001b[0m', | ||
passes = this.totalPasses, | ||
fails = this.totalFailures, | ||
totals = passes + fails, | ||
output; | ||
if (this.totalFailures === 0) { | ||
output = passColor + 'SUMMARY COVERAGE PASS: ' + passes + '/' + totals; | ||
output += ' files passed coverage'; | ||
} else { | ||
output = failColor + 'SUMMARY COVERAGE FAILS: ' + fails + '/' + totals; | ||
output += ' files failed coverage'; | ||
} | ||
console.log(output + originColor); | ||
}, | ||
setupThresholds: function setupThresholds() { | ||
this.thresholds = {}; | ||
if (this.path) { | ||
this.thresholds = require(this.path); | ||
} | ||
}, | ||
getAppThreshold: function getAppThreshold(appName) { | ||
return this.thresholds[appName] || 0; | ||
}, | ||
validateThreshold: function validateThreshold(appName, dataItem) { | ||
return (dataItem.percentage > this.getAppThreshold(appName)); | ||
} | ||
}; | ||
@@ -105,0 +180,0 @@ |
@@ -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 @@ |
{ | ||
"name": "test-agent", | ||
"version": "0.22.13", | ||
"version": "0.22.14", | ||
"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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
255308
7940
23