msw 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -9
- package/lib/iife/index.js +11 -10
- package/lib/iife/index.js.map +1 -1
- package/lib/index.js +11 -10
- package/lib/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/lib/native/index.js +2 -1
- package/lib/native/index.mjs +2 -1
- package/lib/node/index.js +2 -1
- package/lib/node/index.js.map +1 -1
- package/lib/node/index.mjs +2 -1
- package/lib/node/index.mjs.map +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -927,9 +927,10 @@ function prepareRequest(request) {
|
|
|
927
927
|
var import_headers_polyfill6 = require("headers-polyfill");
|
|
928
928
|
function prepareResponse(res) {
|
|
929
929
|
const responseHeaders = (0, import_headers_polyfill6.objectToHeaders)(res.headers);
|
|
930
|
+
const parsedBody = parseBody(res.body, responseHeaders);
|
|
930
931
|
return {
|
|
931
932
|
...res,
|
|
932
|
-
body:
|
|
933
|
+
body: parsedBody
|
|
933
934
|
};
|
|
934
935
|
}
|
|
935
936
|
|
|
@@ -1607,12 +1608,12 @@ async function handleRequest(request, handlers, options, emitter, handleRequestO
|
|
|
1607
1608
|
|
|
1608
1609
|
// src/utils/logging/serializeResponse.ts
|
|
1609
1610
|
var import_headers_polyfill9 = require("headers-polyfill");
|
|
1610
|
-
function serializeResponse(
|
|
1611
|
+
async function serializeResponse(response2) {
|
|
1611
1612
|
return {
|
|
1612
|
-
status:
|
|
1613
|
-
statusText:
|
|
1614
|
-
headers: (0, import_headers_polyfill9.flattenHeadersObject)((0, import_headers_polyfill9.headersToObject)(
|
|
1615
|
-
body:
|
|
1613
|
+
status: response2.status,
|
|
1614
|
+
statusText: response2.statusText,
|
|
1615
|
+
headers: (0, import_headers_polyfill9.flattenHeadersObject)((0, import_headers_polyfill9.headersToObject)(response2.headers)),
|
|
1616
|
+
body: await response2.text()
|
|
1616
1617
|
};
|
|
1617
1618
|
}
|
|
1618
1619
|
|
|
@@ -1653,10 +1654,10 @@ var createRequestListener = (context, options) => {
|
|
|
1653
1654
|
[responseBodyBuffer]
|
|
1654
1655
|
);
|
|
1655
1656
|
if (!options.quiet) {
|
|
1656
|
-
context.emitter.once("response:mocked", (response3) => {
|
|
1657
|
+
context.emitter.once("response:mocked", async (response3) => {
|
|
1657
1658
|
handler.log(
|
|
1658
1659
|
publicRequest,
|
|
1659
|
-
serializeResponse(response3),
|
|
1660
|
+
await serializeResponse(response3),
|
|
1660
1661
|
parsedRequest
|
|
1661
1662
|
);
|
|
1662
1663
|
});
|
|
@@ -1966,10 +1967,10 @@ function createFallbackRequestListener(context, options) {
|
|
|
1966
1967
|
},
|
|
1967
1968
|
onMockedResponse(_, { handler, publicRequest, parsedRequest }) {
|
|
1968
1969
|
if (!options.quiet) {
|
|
1969
|
-
context.emitter.once("response:mocked", (response3) => {
|
|
1970
|
+
context.emitter.once("response:mocked", async (response3) => {
|
|
1970
1971
|
handler.log(
|
|
1971
1972
|
publicRequest,
|
|
1972
|
-
serializeResponse(response3),
|
|
1973
|
+
await serializeResponse(response3),
|
|
1973
1974
|
parsedRequest
|
|
1974
1975
|
);
|
|
1975
1976
|
});
|