Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

test-agent

Package Overview
Dependencies
Maintainers
6
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

test-agent - npm Package Compare versions

Comparing version 0.22.10 to 0.22.11

12

lib/node/bin/server.js

@@ -34,8 +34,2 @@ var server = new (require('../websocket-server')),

option('coverage-thresholds', {
alias: 't',
desc: "Path to coverage thresholds files",
default: './coverage-thresholds.json'
}).
option('growl', {

@@ -97,9 +91,7 @@ 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.BlanketConsoleReporter, {
path: fsPath.join(process.env.PWD, argv['coverage-thresholds'])
});
use(Enhancements.Watcher);

@@ -106,0 +98,0 @@ if(argv.growl){

var Client = require('../../node/client'),
Apps = require('../../node/server'),
optimist = require('optimist'),
fsPath = require('path'),
argv,

@@ -54,6 +53,2 @@ reporters,

}).
option('coverage-thresholds', {
alias: 't',
desc: "Path to coverage thresholds files"
}).
option('server', {

@@ -123,5 +118,3 @@ desc: 'Location of the websocket server to connect to.',

if (enableCoverage) {
client.use(Apps.BlanketConsoleReporter, {
path: fsPath.join(process.env.PWD, argv['coverage-thresholds'])
});
client.use(Apps.BlanketConsoleReporter);
}

@@ -147,12 +140,2 @@

client.on('coverage runner end', function(runner){
client.send('close');
if(runner.totalFailures === 0){
process.exit(0);
}
process.exit(1);
});
client.start();
(function() {
'use strict';
function BlanketConsoleReporter(options) {
for (var key in options) {
if (options.hasOwnProperty(key)) {
this[key] = options[key];
}
}
function BlanketConsoleReporter() {
this.setupThresholds();
this.totalPasses = 0;
this.totalFailures = 0;
}

@@ -18,9 +10,7 @@

enhance: function enhance(worker) {
this.worker = worker;
worker.on('coverage report', this.onCoverageData.bind(this));
worker.on('test runner end', this.onTestRunnerEnd.bind(this));
enhance: function enhance(server) {
server.on('coverage report', this._onCoverageData.bind(this));
},
onCoverageData: function onCoverageData(data) {
_onCoverageData: function _onCoverageData(data) {
data = this._parseCoverageData(data);

@@ -30,7 +20,2 @@ this._printConsoleFormat(data);

onTestRunnerEnd: function onTestRunnerEnd() {
this._printCoverageSummary();
this.worker.emit('coverage runner end', this);
},
_parseCoverageData: function _parseCoverageData(data) {

@@ -46,3 +31,3 @@ var coverResults = [],

var percentage = function(covered, total) {
return Math.round(((covered / total) * 100) * 100) / 100;
return (Math.round(((covered / total) * 100) * 100) / 100) + ' %';
};

@@ -88,19 +73,14 @@

_printConsoleFormat: function _printConsoleFormat(coverResults) {
var appName = coverResults[0].filename.match(/[A-Za-z0-9_-]+/gi)[1],
titleColor = '\u001b[1;36m',
var titleColor = '\u001b[1;36m',
fileNameColor = '\u001b[0;37m',
stmtColor = '\u001b[0;33m',
passColor = '\u001b[0;32m',
failColor = '\u001b[0;31m',
thresholdColor = '\u001b[0;34m',
percentageColor = '\u001b[0;36m',
originColor = '\u001b[0m',
outputFormat,
fails = 0,
totals = coverResults.length - 1;
outputFormat;
// Print title
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);
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);

@@ -111,16 +91,4 @@ // Print coverage result for each file

formatPrefix = (filename === 'Global Total' ? '\n' : ' '),
seperator = ' - ',
isPassThreshold = this.validateThreshold(appName, dataItem),
arrow = isPassThreshold ? ' > ' : ' < ',
covColor = isPassThreshold ? passColor : failColor;
seperator = ' - ';
if (filename !== 'Global Total') {
if (!isPassThreshold) {
fails++;
this.totalFailures++;
} else {
this.totalPasses++;
}
}
filename = (filename === 'Global Total' ? filename :

@@ -131,56 +99,7 @@ (filename.substr(0, filename.indexOf('?')) || filename));

outputFormat += stmtColor + dataItem.stmts + originColor + seperator;
outputFormat += covColor + dataItem.percentage + ' %' + originColor;
outputFormat += percentageColor + 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));
});
}
};

@@ -187,0 +106,0 @@

1

lib/test-agent/browser-worker/mocha-driver.js

@@ -145,2 +145,3 @@ (function(window) {

box.mocha.setup({
ignoreLeaks: true,
globals: globalIgnores,

@@ -147,0 +148,0 @@ ui: self.ui,

@@ -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 = (type === 'trace') ? [(new Error()).stack] : 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,6 +47,4 @@ return e.trim().replace(/^at /, '');

//this is temp
var logDetails = {messages: [message], stack: stack };
var logDetails = { messages: messages, stack: stack };
if (MochaReporter.testAgentEnvId) {

@@ -74,6 +55,14 @@ logDetails.testAgentEnvId = MochaReporter.testAgentEnvId;

MochaReporter.send(
JSON.stringify(['log', logDetails])
JSON.stringify([type, logDetails])
);
};
MochaReporter.console.log = 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');
MochaReporter.console.debug = consoleShim.bind(null, 'log');
runner.on('suite', function onSuite(suite) {

@@ -80,0 +69,0 @@ indentation++;

@@ -93,4 +93,28 @@ (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);
},
'trace': function onTrace(data) {
console.log.apply(console, data.messages);
}
});

@@ -97,0 +121,0 @@ }

{
"name": "test-agent",
"version": "0.22.10",
"version": "0.22.11",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc