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

Function transformRecordedData

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

Source from the content-addressed store, hash-verified

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

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