Comparing version 3.1.3 to 3.1.4
{ | ||
"name": "pactum", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"description": "REST API Testing Tool for all levels in a Test Pyramid", | ||
@@ -63,7 +63,7 @@ "main": "./src/index.js", | ||
"dependencies": { | ||
"@exodus/schemasafe": "^1.0.0-rc.4", | ||
"@exodus/schemasafe": "^1.0.0-rc.6", | ||
"deep-override": "^1.0.2", | ||
"form-data-lite": "^1.0.2", | ||
"json-query": "^2.2.2", | ||
"klona": "^2.0.4", | ||
"klona": "^2.0.5", | ||
"lightcookie": "^1.0.25", | ||
@@ -77,4 +77,4 @@ "openapi-fuzzer-core": "^1.0.6", | ||
"devDependencies": { | ||
"chai": "^4.3.4", | ||
"mocha": "^9.1.2", | ||
"chai": "^4.3.6", | ||
"mocha": "^9.2.0", | ||
"nyc": "^15.1.0", | ||
@@ -81,0 +81,0 @@ "sinon": "^10.0.0" |
const config = { | ||
mock: { | ||
port: process.env.PACTUM_MOCK_PORT || 9393, | ||
host: process.env.PACTUM_MOCK_HOST || '0.0.0.0', | ||
remote: '' | ||
@@ -5,0 +6,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
export interface Have { | ||
interface Have { | ||
status(code: number): void; | ||
@@ -28,7 +28,7 @@ header(key: string, value: any): void; | ||
export interface To { | ||
interface To { | ||
have: Have; | ||
} | ||
export interface Expect { | ||
interface Expect { | ||
to: To; | ||
@@ -35,0 +35,0 @@ should: To; |
@@ -54,2 +54,3 @@ export type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE'; | ||
background?: boolean; | ||
clone?: boolean; | ||
request: InteractionRequest; | ||
@@ -77,2 +78,3 @@ response: InteractionResponse; | ||
export function start(port: number): Promise<void>; | ||
export function start(port: number, host: string): Promise<void>; | ||
@@ -79,0 +81,0 @@ /** |
@@ -13,6 +13,4 @@ const Interaction = require('../models/Interaction.model'); | ||
start(port) { | ||
if (port) { | ||
this.setDefaultPort(port); | ||
} | ||
start(port, host) { | ||
this.setDefaults(port, host) | ||
return this._server.start(); | ||
@@ -25,7 +23,15 @@ }, | ||
setDefaultPort(port) { | ||
if (typeof port !== 'number') { | ||
setDefaults(port, host) { | ||
if (port && typeof port !== 'number') { | ||
throw new PactumConfigurationError(`Invalid port number provided - ${port}`); | ||
} | ||
config.mock.port = port; | ||
if (host && typeof host !== 'string') { | ||
throw new PactumConfigurationError(`Invalid host provided - ${host}`); | ||
} | ||
if (port) { | ||
config.mock.port = port; | ||
} | ||
if (host) { | ||
config.mock.host = host; | ||
} | ||
}, | ||
@@ -32,0 +38,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { InteractionRequest, InteractionResponse, Interaction } from './mock'; | ||
import { InteractionRequest, Interaction } from './mock'; | ||
@@ -22,5 +22,3 @@ export interface SpecRequest { | ||
export interface Interaction { | ||
request: InteractionRequest; | ||
response: InteractionResponse; | ||
export interface ExercisedInteraction extends Interaction { | ||
calls: InteractionCall[]; | ||
@@ -40,3 +38,3 @@ } | ||
recorded?: object; | ||
interactions: Interaction[]; | ||
interactions: ExercisedInteraction[]; | ||
} | ||
@@ -49,3 +47,3 @@ | ||
afterTest(data: object): void; | ||
afterInteraction(data: Interaction): void; | ||
afterInteraction(data: ExercisedInteraction): void; | ||
end(): void | Promise<void> | ||
@@ -52,0 +50,0 @@ } |
@@ -5,5 +5,6 @@ import * as Spec from './models/Spec'; | ||
export * as expect from './exports/expect'; | ||
import expect from './exports/expect'; | ||
export { expect }; | ||
export * as handler from './exports/handler'; | ||
export * as matchers from './exports/matcher'; | ||
export * as mock from './exports/mock'; | ||
@@ -16,3 +17,2 @@ export * as reporter from './exports/reporter'; | ||
export * as state from './exports/state'; | ||
export * as logger from './exports/logger'; | ||
@@ -51,2 +51,4 @@ /** | ||
export function parse(data: any): any; | ||
export namespace pactum { } |
@@ -25,2 +25,10 @@ require('./plugins/logger').setAdapter(require('./adapters/logger')); | ||
const processor = require('./helpers/dataProcessor'); | ||
function parse(data) { | ||
processor.processMaps(); | ||
processor.processTemplates(); | ||
return processor.processData(data); | ||
} | ||
const pactum = { | ||
@@ -63,6 +71,8 @@ | ||
return klona(value); | ||
} | ||
}, | ||
parse | ||
}; | ||
module.exports = pactum; |
@@ -5,2 +5,3 @@ const { setMatchingRules, getValue } = require('pactum-matchers').utils; | ||
const { PactumInteractionError } = require('../helpers/errors'); | ||
const { klona: clone } = require('klona'); | ||
const ALLOWED_REQUEST_METHODS = new Set([ | ||
@@ -192,2 +193,5 @@ 'GET', | ||
let unprocessedResponse; | ||
if (raw && raw.clone) { | ||
raw = clone(raw); | ||
} | ||
if (raw && raw.response) { | ||
@@ -194,0 +198,0 @@ unprocessedResponse = raw.response; |
@@ -28,4 +28,5 @@ const polka = require('polka'); | ||
registerAllRoutes(this, this.app); | ||
this.app.listen(config.mock.port, () => { | ||
log.info(`Mock server is listening on port ${config.mock.port}`); | ||
this.app.listen(config.mock.port, config.mock.host, () => { | ||
const mockAddrInfo = this.app.server.address() | ||
log.info(`Mock server is listening on http://${mockAddrInfo.address}:${mockAddrInfo.port}`); | ||
this._registerEvents(); | ||
@@ -32,0 +33,0 @@ resolve(); |
@@ -201,3 +201,3 @@ import { RequestOptions } from 'http'; | ||
*/ | ||
withMultiPartFormData(key: string, value: string | Buffer | Array | ArrayBuffer, options?: FormData.AppendOptions): Spec; | ||
withMultiPartFormData(key: string, value: string | Buffer | Array<any> | ArrayBuffer, options?: FormData.AppendOptions): Spec; | ||
@@ -399,3 +399,3 @@ /** | ||
*/ | ||
toss(): Promise<T>; | ||
toss(): Promise<any>; | ||
@@ -402,0 +402,0 @@ /** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158262
4744
Updatedklona@^2.0.5