diff --git a/integrations/express/middleware.ts b/integrations/express/middleware.ts index 70eb2be..3f085c1 100644 --- a/integrations/express/middleware.ts +++ b/integrations/express/middleware.ts @@ -94,6 +94,14 @@ export default function middleware( return; } + // Test mode but user is the one who sent the request, not Keploy client + // treat as OFF for this particular request + if (keploy.mode.GetMode() == MODE_TEST) { + createExecutionContext({ mode: MODE_OFF }); + next(); + return; + } + // record mode createExecutionContext({ mode: MODE_RECORD, deps: [], mocks: [] }); captureResp(req, res, next); @@ -151,6 +159,10 @@ export function afterMiddleware(keploy: Keploy, req: Request, res: Response) { return; } + // Test mode but user is the one who sent the request, not Keploy client. + // What's after this condition is related to Record mode. + if (keploy.mode.GetMode() == MODE_TEST) return; + // req.headers // Since, JSON.stingify trims spaces. Therefore, content-length of request header should be updated req.headers["content-length"] = JSON.stringify(