MCPcopy Create free account
hub / github.com/decaporg/decap-cms / transformRecordedData

Function transformRecordedData

cypress/plugins/common.js:34–67  ·  view source on GitHub ↗
(expectation, requestBodySanitizer, responseBodySanitizer)

Source from the content-addressed store, hash-verified

32].map(h => h.toLowerCase());
33
34const transformRecordedData = (expectation, requestBodySanitizer, responseBodySanitizer) => {
35 const { httpRequest, httpResponse } = expectation;
36
37 const responseHeaders = {};
38
39 Object.keys(httpResponse.headers)
40 .filter(key => !HEADERS_TO_IGNORE.includes(key.toLowerCase()))
41 .forEach(key => {
42 responseHeaders[key] = httpResponse.headers[key][0];
43 });
44
45 let queryString;
46 if (httpRequest.queryStringParameters) {
47 const { queryStringParameters } = httpRequest;
48
49 queryString = Object.keys(queryStringParameters)
50 .map(key => `${key}=${queryStringParameters[key]}`)
51 .join('&');
52 }
53
54 const body = requestBodySanitizer(httpRequest);
55 const responseBody = responseBodySanitizer(httpRequest, httpResponse);
56
57 const cypressRouteOptions = {
58 body,
59 method: httpRequest.method,
60 url: queryString ? `${httpRequest.path}?${queryString}` : httpRequest.path,
61 headers: responseHeaders,
62 response: responseBody,
63 status: httpResponse.statusCode,
64 };
65
66 return cypressRouteOptions;
67};
68
69function getGitClient(repoDir) {
70 const git = simpleGit(repoDir).env({ ...process.env, GIT_SSH_COMMAND, GIT_SSL_NO_VERIFY });

Callers

nothing calls this directly

Calls 4

filterMethod · 0.80
mapMethod · 0.80
requestBodySanitizerFunction · 0.70
responseBodySanitizerFunction · 0.70

Tested by

no test coverage detected