Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: record even on test mode #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions integrations/express/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down