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

test-agent

Package Overview
Dependencies
Maintainers
1
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.2.1 to 0.3.0

lib/test-agent/export-error.js

4

HISTORY.md

@@ -0,1 +1,5 @@

# 0.3.0
- Cleaner firefox stacktraces
- New option to change type of required scripts.
# 0.2.0

@@ -2,0 +6,0 @@ - TestAgent.Responder now has .once (per event emitter spec)

14

lib/test-agent/loader.js

@@ -36,3 +36,12 @@ (function(window) {

/**
* javascript content type.
*
*
* @type String
*/
type: 'text/javascript',
/**
* When true will add timestamps to required urls via query param

@@ -127,4 +136,3 @@ *

if (this.bustCache) {
suffix = '?time=' + String(Date.now()) +
'&rand=' + String(Math.random() * 1000);
suffix = '?time=' + String(Date.now());
}

@@ -140,3 +148,3 @@

element.async = false;
element.type = 'text/javascript;version=1.8';
element.type = this.type;
element.onload = function scriptOnLoad() {

@@ -143,0 +151,0 @@ if (callback) {

@@ -103,3 +103,3 @@ (function(window) {

JSON.stringify(
['fail', jsonExport(test, {err: jsonErrorExport(err) })]
['fail', jsonExport(test, {err: TestAgent.exportError(err) })]
)

@@ -123,15 +123,2 @@ );

function jsonErrorExport(err) {
var result = {};
result.stack = err.stack;
result.message = err.message;
result.type = err.type;
result.constructorName = err.constructor.name;
result.expected = err.expected;
result.actual = err.actual;
return result;
}
function jsonExport(object, additional) {

@@ -138,0 +125,0 @@ var result = {}, key;

@@ -123,3 +123,2 @@ (function(exports) {

var self = this;
//console.log(callback.toString());
function onceCb() {

@@ -126,0 +125,0 @@ callback.apply(this, arguments);

{
"name": "test-agent",
"version": "0.2.1",
"version": "0.3.0",
"author": "James Lal",

@@ -5,0 +5,0 @@ "description": "execute client side tests from browser report back to cli",

@@ -385,2 +385,85 @@ // Copyright Joyent, Inc. and other Node contributors.

(function(window) {
if (typeof(window.TestAgent) === 'undefined') {
window.TestAgent = {};
}
var FF_STACK_LINE = /(\w+)?\@(.*):(\d+)/;
var TIME_REGEX = /\?time\=(\d+)/g;
/**
* Returns a formatted stack trace.
*
* @param {String} error error inst Formats a stacktrace.
* @return {String} stack trace.
*/
window.TestAgent.formatStack = function formatStack(err) {
//split stack into lines
var lines,
stack = err.stack,
lineNo,
i = 0,
matches,
stackFunc,
errType,
buffer = '',
stackFile;
if (!err.stack) {
return err.stack;
}
errType = err.type || err.constructor.name || 'Error:';
stack = stack.replace(TIME_REGEX, '');
lines = stack.split('\n');
if (lines[0].match(FF_STACK_LINE)) {
buffer += errType + ': ' + err.message + '\n';
//we are in a firefox stack trace
for (i; i < lines.length; i++) {
matches = FF_STACK_LINE.exec(lines[i]);
if (!matches) {
continue;
}
stackFunc = matches[1] || '(anonymous)';
stackFile = matches[2] || '';
lineNo = matches[3] || '';
buffer += ' at ' + stackFunc +
' (' + stackFile + ':' + lineNo + ')\n';
}
stack = buffer;
}
return stack;
};
/**
* Accepts an instance of error and
* creates a object that can be sent
* to the test agent server to be used
* in error reporting.
*
*
* @param {Error|Object} err error instance.
*/
window.TestAgent.exportError = function(err) {
var errorObject = {};
errorObject.stack = this.formatStack(err);
errorObject.message = err.message;
errorObject.type = err.type;
errorObject.constructorName = err.constructor.name;
errorObject.expected = err.expected;
errorObject.actual = err.actual;
return errorObject;
};
}(this));
(function(exports) {

@@ -508,3 +591,2 @@ 'use strict';

var self = this;
//console.log(callback.toString());
function onceCb() {

@@ -631,3 +713,12 @@ callback.apply(this, arguments);

/**
* javascript content type.
*
*
* @type String
*/
type: 'text/javascript',
/**
* When true will add timestamps to required urls via query param

@@ -722,4 +813,3 @@ *

if (this.bustCache) {
suffix = '?time=' + String(Date.now()) +
'&rand=' + String(Math.random() * 1000);
suffix = '?time=' + String(Date.now());
}

@@ -735,3 +825,3 @@

element.async = false;
element.type = 'text/javascript;version=1.8';
element.type = this.type;
element.onload = function scriptOnLoad() {

@@ -1276,3 +1366,3 @@ if (callback) {

JSON.stringify(
['fail', jsonExport(test, {err: jsonErrorExport(err) })]
['fail', jsonExport(test, {err: TestAgent.exportError(err) })]
)

@@ -1296,15 +1386,2 @@ );

function jsonErrorExport(err) {
var result = {};
result.stack = err.stack;
result.message = err.message;
result.type = err.type;
result.constructorName = err.constructor.name;
result.expected = err.expected;
result.actual = err.actual;
return result;
}
function jsonExport(object, additional) {

@@ -1311,0 +1388,0 @@ var result = {}, key;

@@ -6,2 +6,3 @@ {

"/test/test-agent/browser-worker/config-test.js",
"/test/test-agent/browser-worker/error-reporting-test.js",
"/test/test-agent/browser-worker/mocha-driver-test.js",

@@ -11,2 +12,4 @@ "/test/test-agent/browser-worker/test-ui-test.js",

"/test/test-agent/config-test.js",
"/test/test-agent/export-error-test.js",
"/test/test-agent/inspect-test.js",
"/test/test-agent/loader-test.js",

@@ -16,5 +19,4 @@ "/test/test-agent/pool-base-test.js",

"/test/test-agent/sandbox-test.js",
"/test/test-agent/inspect-test.js",
"/test/test-agent/websocket-client-test.js"
]
}
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