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.7.3 to 3.7.4

2

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

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

@@ -0,4 +1,4 @@

import { IncomingMessage } from 'http';
import * as Spec from '../models/Spec';
import { Interaction } from './mock';
import { IncomingMessage } from 'http';

@@ -127,2 +127,8 @@ interface PactumRequest {

*/
export function addWaitHandler(name: string, func: WaitHandlerFunction): void;
export function addWaitHandler(name: string, func: WaitHandlerFunction): void;
/**
* adds a response handler
* @see https://pactumjs.github.io/api/handlers/addResponseHandler.html
*/
export function addResponseHandler(name: string, func: RetryHandlerFunction): void;

@@ -13,2 +13,3 @@ const { PactumHandlerError } = require('../helpers/errors');

const waitHandlers = {};
const responseHandlers = {};

@@ -62,2 +63,7 @@ const handler = {

addResponseHandler(name, func) {
isValidHandler(name, func);
responseHandlers[name] = func;
},
getStateHandler(name) {

@@ -107,2 +113,7 @@ if (stateHandlers[name]) return stateHandlers[name];

throw new PactumHandlerError(`Wait Handler Not Found - '${name}'`);
},
getResponseHandler(name) {
if (responseHandlers[name]) return responseHandlers[name];
throw new PactumHandlerError(`Response Handler Not Found - '${name}'`);
}

@@ -109,0 +120,0 @@

@@ -43,2 +43,6 @@ const handler = require('../exports/handler');

return handler.getRetryHandler(name)(ctx);
},
response(name, ctx) {
return handler.getResponseHandler(name)(ctx);
}

@@ -45,0 +49,0 @@

@@ -9,2 +9,3 @@ const lc = require('lightcookie');

const stash = require('../exports/stash');
const logger = require('../plugins/logger');

@@ -148,2 +149,14 @@ function getCaptureHandlerName(name) {

async function runResponseHandler(spec) {
try {
const ctx = { req: spec._request, res: spec._response };
const handlers = spec._response_handlers;
for (let i = 0; i < handlers.length; i++) {
await hr.response(handlers[i], ctx);
}
} catch (error) {
logger.warn(`Error running response handler: ${error}`);
}
}
module.exports = {

@@ -154,3 +167,4 @@ storeSpecData,

storeInteractionData,
getPathValueFromRequestResponse
getPathValueFromRequestResponse,
runResponseHandler
};

@@ -57,2 +57,4 @@ import FormData from 'form-data-lite';

useResponseHandler(key: string): Spec;
/**

@@ -59,0 +61,0 @@ * The GET method requests a representation of the specified resource.

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

this._data_maps = [];
this._response_handlers = [];
this._specHandlerData = data;

@@ -85,2 +86,7 @@ this._sleep = '';

useResponseHandler(key) {
this._response_handlers.push(key);
return this;
}
get(url) {

@@ -87,0 +93,0 @@ validateRequestUrl(this._request, url);

@@ -80,2 +80,4 @@ const phin = require('phin');

this.response = await getResponse(this);
this.spec._response = this.response;
await th.runResponseHandler(this.spec);
const options = this.request.retryOptions;

@@ -82,0 +84,0 @@ if (options) {

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