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.1.8 to 3.1.9

2

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

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

@@ -5,3 +5,3 @@ export type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE';

query: string;
variables?: string;
variables?: object;
}

@@ -17,2 +17,3 @@

body?: any;
form?: object;
}

@@ -75,3 +76,3 @@

* starts the mock server
* @see https://pactumjs.github.io/#/mock-server
* @see https://pactumjs.github.io/guides/mock-server.html
*/

@@ -84,3 +85,3 @@ export function start(): Promise<void>;

* stops the mock server
* @see https://pactumjs.github.io/#/mock-server
* @see https://pactumjs.github.io/guides/mock-server.html
*/

@@ -91,3 +92,4 @@ export function stop(): Promise<void>;

* adds a interaction
* @see https://pactumjs.github.io/#/mock-server
* @see https://pactumjs.github.io/guides/mock-server.html
* @see https://pactumjs.github.io/api/mock/interaction.html
*/

@@ -103,3 +105,3 @@ export function addInteraction(interaction: Interaction): string | Promise<string>;

* returns interaction details
* @see https://pactumjs.github.io/#/mock-server
* @see https://pactumjs.github.io/guides/mock-server.html
*/

@@ -111,3 +113,3 @@ export function getInteraction(id: string): InteractionDetails | Promise<InteractionDetails>;

* removes specified interaction from the mock server
* @see https://pactumjs.github.io/#/mock-server
* @see https://pactumjs.github.io/guides/mock-server.html
*/

@@ -119,3 +121,3 @@ export function removeInteraction(id: string): void | Promise<void>;

* clears all interactions from the server
* @see https://pactumjs.github.io/#/mock-server
* @see https://pactumjs.github.io/guides/mock-server.html
*/

@@ -127,4 +129,4 @@ export function clearInteractions(): void;

* all methods in mock will return promises
* @see https://pactumjs.github.io/#/mock-server
* @see https://pactumjs.github.io/guides/mock-server.html
*/
export function useRemoteServer(url: string): void;

@@ -51,3 +51,3 @@ import { InteractionRequest, Interaction } from './mock';

* adds custom reporters
* @see https://pactumjs.github.io/#/api-reporter
* @see https://pactumjs.github.io/guides/reporting.html
*/

@@ -58,4 +58,4 @@ export function add(reporter: Reporter): void;

* runs end function of all added reporters
* @see https://pactumjs.github.io/#/api-reporter
* @see https://pactumjs.github.io/guides/reporting.html
*/
export function end(): Promise<void>;

@@ -150,12 +150,14 @@ const { compare } = require('pactum-matchers').utils;

const { strict, request } = interaction;
const actual_request_body = request.form ? parseFormBody(req.body) : req.body;
const expected_request_body = request.form ? request.form : request.body;
if (request.graphQL && req.method !== 'GET') {
return graphQL.compare(req.body, request.body, strict);
return graphQL.compare(actual_request_body, expected_request_body, strict);
}
if (strict) {
if (req.body || request.body) {
return compare(req.body, request.body, request.matchingRules, '$.body', strict);
if (actual_request_body || expected_request_body) {
return compare(actual_request_body, expected_request_body, request.matchingRules, '$.body', strict);
}
} else {
if (request.body) {
return compare(req.body, request.body, request.matchingRules, '$.body', strict);
if (expected_request_body) {
return compare(actual_request_body, expected_request_body, request.matchingRules, '$.body', strict);
}

@@ -166,2 +168,11 @@ }

function parseFormBody(form_string) {
const form = {};
const params = new URLSearchParams(form_string);
for (const [name, value] of params) {
form[name] = value;
}
return form;
}
module.exports = utils;

@@ -149,2 +149,6 @@ const { setMatchingRules, getValue } = require('pactum-matchers').utils;

}
if (request.form) {
setMatchingRules(this.matchingRules, request.form, '$.body');
this.form = getValue(request.form);
}
}

@@ -151,0 +155,0 @@ }

@@ -1,2 +0,2 @@

import { RequestOptions } from 'http';
import { RequestOptions, IncomingMessage } from 'http';
import FormData from 'form-data-lite';

@@ -389,6 +389,12 @@ import { Interaction } from '../exports/mock';

/**
* saves response in file system
* @see https://pactumjs.github.io/api/requests/save.html
*/
save(path: string): Spec;
/**
* executes the test case
* @see https://pactumjs.github.io/api/requests/toss.html
*/
toss(): Promise<any>;
toss(): Promise<IncomingMessage> | Promise<any>;

@@ -395,0 +401,0 @@ /**

@@ -36,2 +36,3 @@ const fd = require('../plugins/form.data')

this._wait = null;
this._save = null;
this._specHandlerData = data;

@@ -476,2 +477,7 @@ hr.spec(name, data, this);

save(path) {
this._save = path;
return this;
}
async toss() {

@@ -478,0 +484,0 @@ const tosser = new Tosser(this);

const phin = require('phin');
const fs = require('fs');
const helper = require('../helpers/helper');

@@ -40,2 +41,3 @@ const log = require('../plugins/logger');

await this.getInteractionsFromServer();
this.saveDataInFileSystem();
this.recordData();

@@ -169,2 +171,8 @@ th.storeSpecData(this.spec, this.spec._stores);

saveDataInFileSystem() {
if (this.spec._save && this.response.buffer) {
fs.writeFileSync(this.spec._save, this.response.buffer);
}
}
recordData() {

@@ -171,0 +179,0 @@ const defaultRecorders = request.getDefaultRecorders();

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