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

pactum

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pactum - npm Package Compare versions

Comparing version 3.5.0 to 3.5.1

2

package.json
{
"name": "pactum",
"version": "3.5.0",
"version": "3.5.1",
"description": "REST API Testing Tool for all levels in a Test Pyramid",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -8,2 +8,3 @@ const assert = require('assert');

const utils = require('../helpers/utils');
const helper = require('../helpers/helper');
const file = require('../helpers/file.utils');

@@ -384,12 +385,20 @@ const log = require('../plugins/logger');

_validateJsonLengthQuery(response) {
const allowedRules = ['LTE', 'GTE', 'LT', 'GT', 'NOT_EQUALS']
this.jsonLengthQuery = processor.processData(this.jsonLengthQuery);
for (let i = 0; i < this.jsonLengthQuery.length; i++) {
const { path, value: expected } = this.jsonLengthQuery[i];
const actualValue = jqy(path, { data: response.json }).value;
if (actualValue && Array.isArray(actualValue)) {
const actual = actualValue.length;
assert.strictEqual(actual, expected, `JSON Length ${actual} !== ${expected}`);
} else {
this.fail(`Response does not contain a json array at '${path}'`);
const jQ = clone(this.jsonLengthQuery[i]);
const actualValue = jqy(jQ.path, { data: response.json }).value;
const rules = jmv.getMatchingRules(jQ.value, jQ.path);
const expectedValue = jmv.getRawValue(jQ.value);
if (!actualValue && !Array.isArray(actualValue)) {
this.fail(`Response does not contain a json array at '${jQ.path}'`);
}
if (helper.isValidObject(jQ.value) && !allowedRules.includes(jQ.value.pactum_type)) {
this.fail(`Invalid compare operation ${jQ.value.pactum_type}, allowed operations: ${allowedRules}`);
}
const errors = jmv.validate(actualValue.length, expectedValue, rules, jQ.path);
if (errors) {
const errCondition = jQ.value.pactum_type ? `not ${jQ.value.pactum_type}` : "!==";
this.fail(`JSON Length ${actualValue.length} ${errCondition} ${expectedValue}`);
}
}

@@ -396,0 +405,0 @@ }

@@ -337,2 +337,3 @@ import { RequestOptions, IncomingMessage } from 'http';

expectJsonLength(path: string, value: number): Spec;
expectJsonLength(path: string, matcher: object): Spec;

@@ -339,0 +340,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