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

test-machinepack

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

test-machinepack - npm Package Compare versions

Comparing version 2.1.10 to 2.1.11

4

package.json
{
"name": "test-machinepack",
"author": "Mike McNeil <@mikermcneil>",
"version": "2.1.10",
"version": "2.1.11",
"description": "Raw test runner for machinepacks (also includes a simple stub test driver)",

@@ -19,2 +19,4 @@ "keywords": [

"async": "0.9.2",
"chalk": "^1.1.3",
"json-diff": "0.3.1",
"json5": "0.4.0",

@@ -21,0 +23,0 @@ "lodash": "3.9.1",

@@ -8,4 +8,6 @@ /**

var async = require('async');
var JsonDiffer = require('json-diff');
var Machines = require('machinepack-machines');
var rttc = require('rttc');
var chalk = require('chalk');

@@ -170,5 +172,8 @@

// TODO: support `maxDuration` assertion
// (but this should be accomplished by just calling testMachine()-- it's already implemented there)
tookTooLong: false,
// TODO: support `after` assertion (custom asynchronous function)
// We could eventually support `postConditions` here
// (maybe relevant for json5 files that can support functions)
// (but if we do it, this should be accomplished by just calling testMachine()-- it's already implemented there.)
failedPostcondition: false

@@ -247,3 +252,25 @@ };

if (testResultObj.wrongOutput) {
_testFailedErr.message += util.format(' Expected output was: `%s` (a %s) -- but actually the machine returned: `%s` (a %s)', util.inspect(outputAssertion, false, null), rttc.getDisplayType(outputAssertion), util.inspect(_testFailedErr.actual.output, false, null), rttc.getDisplayType(_testFailedErr.actual.output));
// Showing full expected output AND actual output can get really overwhelming sometimes.
// So we check how big this stuff is before showing that.
//
// If the expected output AND actual output are both objects of some kind (could be arrays
// too) then try to compute the JSON diff and use that.
var diffStr;
if (_.isObject(testResultObj.actual.output) && _.isObject(outputAssertion)){
try {
diffStr = JsonDiffer.diffString(testResultObj.actual.output, outputAssertion);
} catch (e) { /*ignore errors here-- we just use the more basic output if that happens */ }
}
if (diffStr) {
_testFailedErr.message += util.format(
' Expected output was a %s -- but actually the machine returned a %s. (diff below...)\n'+
chalk.reset(' Diff:'), rttc.getDisplayType(outputAssertion), rttc.getDisplayType(testResultObj.actual.output), diffStr);
}
// If that doesn't work, or if either the expected or actual output is a non-object,
// then just show the normal expected vs. actual message:
else {
_testFailedErr.message += util.format(' Expected output was: `%s` (a %s) -- but actually the machine returned: `%s` (a %s)', util.inspect(outputAssertion, false, null), rttc.getDisplayType(outputAssertion), util.inspect(whatActuallyHappened.output, false, null), rttc.getDisplayType(testResultObj.actual.output));
}
}

@@ -250,0 +277,0 @@

@@ -127,3 +127,6 @@ module.exports = require('machine').build({

var rttc = require('rttc');
var JsonDiffer = require('json-diff');
var chalk = require('chalk');
if (_.isArray(inputs.using) || !_.isObject(inputs.using)) {

@@ -374,3 +377,24 @@ return exits.error('Invalid input value for `using`. Should be a dictionary of input values.');

if (failureReport.wrongOutput) {
failureReport.message += util.format(' Expected output was: `%s` (a %s) -- but actually the machine returned: `%s` (a %s)', util.inspect(outputAssertion, false, null), rttc.getDisplayType(outputAssertion), util.inspect(whatActuallyHappened.output, false, null), rttc.getDisplayType(failureReport.actual.output));
// Showing full expected output AND actual output can get really overwhelming sometimes.
// So we check how big this stuff is before showing that.
//
// If the expected output AND actual output are both objects of some kind (could be arrays
// too) then try to compute the JSON diff and use that.
var diffStr;
if (_.isObject(failureReport.actual.output) && _.isObject(outputAssertion)){
try {
diffStr = JsonDiffer.diffString(failureReport.actual.output, outputAssertion);
} catch (e) { /*ignore errors here-- we just use the more basic output if that happens */ }
}
if (diffStr) {
failureReport.message += util.format(
' Expected output was a %s -- but actually the machine returned a %s. (diff below...)\n'+
chalk.reset(' Diff:'), rttc.getDisplayType(outputAssertion), rttc.getDisplayType(failureReport.actual.output), diffStr);
}
// If that doesn't work, or if either the expected or actual output is a non-object,
// then just show the normal expected vs. actual message:
else {
failureReport.message += util.format(' Expected output was: `%s` (a %s) -- but actually the machine returned: `%s` (a %s)', util.inspect(outputAssertion, false, null), rttc.getDisplayType(outputAssertion), util.inspect(whatActuallyHappened.output, false, null), rttc.getDisplayType(failureReport.actual.output));
}
}

@@ -377,0 +401,0 @@

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