diff --git a/mock/mock.ts b/mock/mock.ts index 3c8cfc9..f8ca4f3 100644 --- a/mock/mock.ts +++ b/mock/mock.ts @@ -25,6 +25,8 @@ export interface Config { Name: string; Path: string; Mode: string; + Remove?: string[]; + Replace?: { [key: string]: string }; } export function NewContext(conf: Config) { let mode = MODE_TEST, @@ -88,6 +90,8 @@ export function NewContext(conf: Config) { testId: conf.Name, mocks: [], fileExport: true, + Remove: conf.Remove, + Replace: conf.Replace, }); break; default: diff --git a/mock/utils.ts b/mock/utils.ts index cbeee52..6cac1cf 100644 --- a/mock/utils.ts +++ b/mock/utils.ts @@ -1,9 +1,11 @@ import { response } from "express"; import { Mock } from "../proto/services/Mock"; +import { getExecutionContext } from "../src/context"; import { grpcClient, MockIds, mockPath } from "./mock"; export function putMocks(mock: Mock) { - grpcClient.PutMock({ Path: mockPath, Mock: mock }, (err, response) => { + const ctx = getExecutionContext().context + grpcClient.PutMock({ Path: mockPath, Mock: mock, Remove:ctx.Remove, Replace:ctx.Replace }, (err, response) => { if (err !== null) { console.error(err); } diff --git a/src/keploy.ts b/src/keploy.ts index 1de2cca..d69c201 100644 --- a/src/keploy.ts +++ b/src/keploy.ts @@ -29,6 +29,8 @@ export const V1_BETA2 = "api.keploy.io/v1beta2", type AppConfigFilter = { urlRegex?: string; + remove?: string[]; + replace?: { [key: string]: string }; }; type AppConfig = { @@ -163,6 +165,8 @@ export default class Keploy { } capture(req: TestCaseReq) { + req.Remove=this.appConfig.filter.remove + req.Replace=this.appConfig.filter.replace return this.put(req); }