New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

artillery-plugin-expect

Package Overview
Dependencies
Maintainers
2
Versions
368
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

artillery-plugin-expect - npm Package Compare versions

Comparing version 1.5.0 to 2.0.0-dev1

test/lib/formatters.js

14

index.js

@@ -19,2 +19,12 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

function ExpectationsPlugin(script, events) {
if(!global.artillery && !global.artillery.log) {
console.error('This plugin requires Artillery v2');
return;
}
if (typeof process.env.WORKER_ID === 'undefined') {
debug('Not running in a worker, exiting');
return;
}
this.script = script;

@@ -74,5 +84,5 @@ this.events = events;

if (userContext.expectationsPlugin.outputFormat === 'json') {
console.log(JSON.stringify({ ok: false, error: scenarioErr.message }));
artillery.log(JSON.stringify({ ok: false, error: scenarioErr.message }));
} else {
console.log(chalk.red('Error:'), scenarioErr.message);
artillery.log(`${chalk.red('Error:')} ${scenarioErr.message}`);
}

@@ -79,0 +89,0 @@ return done();

43

lib/formatters.js

@@ -13,10 +13,8 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

pretty: prettyPrint,
json: jsonPrint
json: jsonPrint,
prettyError: prettyError
};
function prettyPrint(requestExpectations, req, res, userContext) {
console.log(
chalk.blue('*', req.method, urlparse(req.url).path),
req.name ? '- ' + req.name : ''
);
artillery.log(`${chalk.blue('*', req.method, urlparse(req.url).path)} ${req.name ? '- ' + req.name : ''}`, {});

@@ -26,11 +24,11 @@ let hasFailedExpectations = false;

requestExpectations.results.forEach(result => {
console.log(
artillery.log(
` ${result.ok ? chalk.green('ok') : chalk.red('not ok')} ${
result.type
} ${result.got} `
} ${result.got} `, {}
);
if (!result.ok) {
console.log(' expected:', result.expected);
console.log(' got:', result.got);
artillery.log(` expected: ${result.expected}`);
artillery.log(` got: ${result.got}`);

@@ -47,15 +45,15 @@ hasFailedExpectations = true;

function printExchangeContext(req, res, userContext) {
console.log(chalk.yellow(' Request params:'));
console.log(prepend(req.url, ' '));
console.log(prepend(JSON.stringify(req.json || '', null, 2), ' '));
console.log(chalk.yellow(' Headers:'));
artillery.log(chalk.yellow(' Request params:'));
artillery.log(prepend(req.url, ' '));
artillery.log(prepend(JSON.stringify(req.json || '', null, 2), ' '));
artillery.log(chalk.yellow(' Headers:'));
Object.keys(res.headers).forEach(function(h) {
console.log(' ', h, ':', res.headers[h]);
artillery.log(` ${h}: ${res.headers[h]}`);
});
console.log(chalk.yellow(' Body:'));
console.log(prepend(String(JSON.stringify(res.body, null, 2)), ' '));
artillery.log(chalk.yellow(' Body:'));
artillery.log(prepend(String(JSON.stringify(res.body, null, 2)), ' '));
console.log(chalk.yellow(' User variables:'));
artillery.log(chalk.yellow(' User variables:'));
Object.keys(userContext.vars).filter(varName => varName !== '$processEnvironment').forEach(function(varName) {
console.log(' ', varName, ':', userContext.vars[varName]);
artillery.log(` ${varName}: ${userContext.vars[varName]}`);
});

@@ -65,5 +63,12 @@ }

function jsonPrint(requestExpectations, req, res, userContext) {
console.log(JSON.stringify(requestExpectations));
artillery.log(JSON.stringify(requestExpectations));
}
function prettyError(requestExpectations, req, res, userContext) {
if (requestExpectations.results.find(result => !result.ok) === undefined) {
return;
}
prettyPrint(requestExpectations, req, res, userContext);
}
function prepend(text, str) {

@@ -70,0 +75,0 @@ return text

{
"name": "artillery-plugin-expect",
"version": "1.5.0",
"version": "2.0.0-dev1",
"description": "Expectations and assertions for HTTP",

@@ -20,3 +20,3 @@ "main": "index.js",

"@commitlint/config-conventional": "^7.6.0",
"artillery": "^1.7.5",
"artillery": "^2.0.0-dev10",
"ava": "^3.8.1",

@@ -23,0 +23,0 @@ "husky": "^1.3.1",

@@ -19,3 +19,4 @@ 'use strict';

template: require('artillery/util').template
}
},
log: console.log.bind(console)
};

@@ -140,3 +141,3 @@

[ 'json', {}, 'charset=utf-8; application/problem+json', {}, true ],
[ 'text/plain', 'string', 'text/plain', {}, true ],

@@ -169,3 +170,3 @@ [ 'TEXT/PLAIN', 'string', 'text/plain', {}, true ],

const result = shelljs.exec(
`${__dirname}/../node_modules/.bin/artillery run ${__dirname}/pets-test.yaml`,
`${__dirname}/../node_modules/.bin/artillery run --solo -q ${__dirname}/pets-test.yaml`,
{

@@ -172,0 +173,0 @@ silent: false

Sorry, the diff of this file is not supported yet

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