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

pactum

Package Overview
Dependencies
Maintainers
1
Versions
113
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.6.7 to 3.6.8

2

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

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

export interface Have {
status(code: number): void;
status(code: number, message?: string): void;
header(key: string, value: any): void;

@@ -4,0 +4,0 @@ headerContains(key: string, value: any): void;

@@ -12,4 +12,5 @@ const ExpectModel = require('../models/expect');

status(code) {
status(code, message = '') {
this.expect.statusCode = code;
this.expect.customMessage = message;
this._validate();

@@ -16,0 +17,0 @@ }

@@ -70,3 +70,3 @@ /**

/**
*
*
* @example

@@ -73,0 +73,0 @@ * stash.addDataTemplate('USER:NEW', { name: 'john', age: 28 });

const { URL } = require('url');
const stash = require('../exports/stash');
const processor = require('./dataProcessor');

@@ -9,3 +10,4 @@ const helper = require('./helper');

process(request) {
process(request, local_data_maps) {
process_local_data_maps(local_data_maps);
processor.processMaps();

@@ -30,2 +32,14 @@ processor.processTemplates();

/**
*
* @param {any[]} local_data_maps
*/
function process_local_data_maps(local_data_maps) {
if (local_data_maps) {
for (const local_data_map of local_data_maps) {
stash.addDataMap(local_data_map.key, local_data_map.value);
}
}
}
function setBaseUrl(request) {

@@ -112,3 +126,3 @@ if (config.request.baseUrl && request.url && !request.url.startsWith('http')) {

const { key, value, options } = request._multi_parts[i];
if (key instanceof FormData) {
if (key instanceof FormData) {
multi_part_form_data = key;

@@ -126,3 +140,3 @@ } else {

}
}

@@ -129,0 +143,0 @@ }

@@ -105,3 +105,4 @@ const assert = require('assert');

if (this.statusCode !== null) {
assert.strictEqual(response.statusCode, this.statusCode, `HTTP status ${response.statusCode} !== ${this.statusCode}`);
const message = this.customMessage ? `${this.customMessage}\n ` : '';
assert.strictEqual(response.statusCode, this.statusCode, `${message}HTTP status ${response.statusCode} !== ${this.statusCode}`);
}

@@ -348,3 +349,3 @@ }

file.saveSnapshot(snapshot_name, response.json);
}
}
if (value) {

@@ -359,3 +360,3 @@ const current_rules = jmv.getMatchingRules(value, '$.body');

}
const expected = file.getSnapshotFile(snapshot_name, response.json);

@@ -425,5 +426,12 @@ if (Object.keys(all_rules).length > 0) {

if (typeof expected === 'string') {
const actual = response.toString();
if (!actual.includes(expected)) {
this.fail(`Error - "${actual}" doesn't include - ${expected}`);
if (response.errors && Array.isArray(response.errors) && response.errors.length > 0) {
const actual = response.errors[0].toString();
if (!actual.includes(expected)) {
this.fail(`Error - "${actual}" doesn't include - ${expected}`);
}
} else {
const actual = response.toString();
if (!actual.includes(expected)) {
this.fail(`Error - "${actual}" doesn't include - ${expected}`);
}
}

@@ -430,0 +438,0 @@ }

@@ -52,2 +52,6 @@ import FormData from 'form-data-lite';

useDataMap(map: object): Spec;
useDataMap(maps: object[]): Spec;
useDataMap(key: string, value: any): Spec;
/**

@@ -254,3 +258,3 @@ * The GET method requests a representation of the specified resource.

*/
expectStatus(code: number): Spec;
expectStatus(code: number, message?: string): Spec;

@@ -257,0 +261,0 @@ /**

@@ -40,2 +40,3 @@ const fs = require('fs');

this._save = null;
this._data_maps = [];
this._specHandlerData = data;

@@ -73,2 +74,7 @@ hr.spec(name, data, this);

useDataMap(key, value) {
this._data_maps.push({ key, value });
return this;
}
get(url) {

@@ -162,6 +168,6 @@ validateRequestUrl(this._request, url);

if (Object.keys(this._request.queryParams).includes(key)) {
if (!Array.isArray(this._request.queryParams[key])) {
this._request.queryParams[key] = [this._request.queryParams[key]];
}
this._request.queryParams[key].push(value);
if (!Array.isArray(this._request.queryParams[key])) {
this._request.queryParams[key] = [this._request.queryParams[key]];
}
this._request.queryParams[key].push(value);
} else {

@@ -351,4 +357,5 @@ this._request.queryParams[key] = value;

expectStatus(statusCode) {
expectStatus(statusCode, message = '') {
this._expect.statusCode = statusCode;
this._expect.customMessage = message;
return this;

@@ -436,3 +443,3 @@ }

expectJsonSnapshot(name, value) {
typeof name === 'string' ? this._expect.jsonSnapshots.push({ name, value }): this._expect.jsonSnapshots.push({ value: name });
typeof name === 'string' ? this._expect.jsonSnapshots.push({ name, value }) : this._expect.jsonSnapshots.push({ value: name });
return this;

@@ -439,0 +446,0 @@ }

@@ -31,3 +31,3 @@ const phin = require('phin');

this.spec.start = Date.now().toString();
this.request = requestProcessor.process(this.request);
this.request = requestProcessor.process(this.request, this.spec._data_maps);
await this.setState();

@@ -34,0 +34,0 @@ await this.addInteractionsToServer();

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