@zimic/interceptor 0.16.0-canary.7 → 0.16.0-canary.9
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/dist/{chunk-NY62MKKU.mjs → chunk-NTRC2S4I.mjs} +5 -5
- package/dist/chunk-NTRC2S4I.mjs.map +1 -0
- package/dist/{chunk-HYJ5EZ6I.js → chunk-O6ZIPCUJ.js} +6 -6
- package/dist/chunk-O6ZIPCUJ.js.map +1 -0
- package/dist/cli.js +9 -9
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/http.js +14 -14
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +13 -13
- package/dist/http.mjs.map +1 -1
- package/dist/server.js +6 -6
- package/dist/server.mjs +1 -1
- package/package.json +5 -5
- package/src/cli/browser/init.ts +2 -2
- package/src/http/interceptorWorker/HttpInterceptorWorker.ts +2 -2
- package/src/http/requestHandler/errors/TimesCheckError.ts +10 -10
- package/src/utils/console.ts +2 -2
- package/dist/chunk-HYJ5EZ6I.js.map +0 -1
- package/dist/chunk-NY62MKKU.mjs.map +0 -1
package/dist/http.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import color2 from 'picocolors';
|
|
2
2
|
import { HttpHeaders, HttpSearchParams, HttpFormData, HTTP_METHODS, HTTP_METHODS_WITH_RESPONSE_BODY } from '@zimic/http';
|
|
3
3
|
import { http, passthrough } from 'msw';
|
|
4
4
|
import * as mswBrowser from 'msw/browser';
|
|
@@ -248,7 +248,7 @@ __name(formatValueToLog, "formatValueToLog");
|
|
|
248
248
|
function logWithPrefix(messageOrMessages, options = {}) {
|
|
249
249
|
const { method = "log" } = options;
|
|
250
250
|
const messages = Array.isArray(messageOrMessages) ? messageOrMessages : [messageOrMessages];
|
|
251
|
-
console[method](
|
|
251
|
+
console[method](color2.cyan("[@zimic/interceptor]"), ...messages);
|
|
252
252
|
}
|
|
253
253
|
__name(logWithPrefix, "logWithPrefix");
|
|
254
254
|
|
|
@@ -274,8 +274,8 @@ function createMessageHeader({
|
|
|
274
274
|
|
|
275
275
|
Requests evaluated by this handler:
|
|
276
276
|
|
|
277
|
-
${
|
|
278
|
-
${
|
|
277
|
+
${color2.green("- Expected")}
|
|
278
|
+
${color2.red("+ Received")}`
|
|
279
279
|
].filter((part) => part !== false).join("");
|
|
280
280
|
}
|
|
281
281
|
__name(createMessageHeader, "createMessageHeader");
|
|
@@ -290,22 +290,22 @@ function createMessageDiffs({ requestSaving, unmatchedRequestGroups }) {
|
|
|
290
290
|
messageParts.push("Computed restriction:");
|
|
291
291
|
const stringifiedExpected = stringifyValueToLog(diff.computed.expected);
|
|
292
292
|
const stringifiedReceived = stringifyValueToLog(diff.computed.received);
|
|
293
|
-
messageParts.push(` ${
|
|
294
|
-
messageParts.push(` ${
|
|
293
|
+
messageParts.push(` ${color2.green(`- return ${stringifiedExpected}`)}`);
|
|
294
|
+
messageParts.push(` ${color2.red(`+ return ${stringifiedReceived}`)}`);
|
|
295
295
|
}
|
|
296
296
|
if (diff.headers) {
|
|
297
297
|
messageParts.push("Headers:");
|
|
298
298
|
const stringifiedExpected = stringifyValueToLog(diff.headers.expected);
|
|
299
299
|
const stringifiedReceived = stringifyValueToLog(diff.headers.received);
|
|
300
|
-
messageParts.push(` ${
|
|
301
|
-
messageParts.push(` ${
|
|
300
|
+
messageParts.push(` ${color2.green(`- ${stringifiedExpected}`)}`);
|
|
301
|
+
messageParts.push(` ${color2.red(`+ ${stringifiedReceived}`)}`);
|
|
302
302
|
}
|
|
303
303
|
if (diff.searchParams) {
|
|
304
304
|
messageParts.push("Search params:");
|
|
305
305
|
const stringifiedExpected = stringifyValueToLog(diff.searchParams.expected);
|
|
306
306
|
const stringifiedReceived = stringifyValueToLog(diff.searchParams.received);
|
|
307
|
-
messageParts.push(` ${
|
|
308
|
-
messageParts.push(` ${
|
|
307
|
+
messageParts.push(` ${color2.green(`- ${stringifiedExpected}`)}`);
|
|
308
|
+
messageParts.push(` ${color2.red(`+ ${stringifiedReceived}`)}`);
|
|
309
309
|
}
|
|
310
310
|
if (diff.body) {
|
|
311
311
|
messageParts.push("Body:");
|
|
@@ -315,8 +315,8 @@ function createMessageDiffs({ requestSaving, unmatchedRequestGroups }) {
|
|
|
315
315
|
const stringifiedReceived = stringifyValueToLog(diff.body.received, {
|
|
316
316
|
includeClassName: { searchParams: true }
|
|
317
317
|
});
|
|
318
|
-
messageParts.push(` ${
|
|
319
|
-
messageParts.push(` ${
|
|
318
|
+
messageParts.push(` ${color2.green(`- ${stringifiedExpected}`)}`);
|
|
319
|
+
messageParts.push(` ${color2.red(`+ ${stringifiedReceived}`)}`);
|
|
320
320
|
}
|
|
321
321
|
return messageParts.join("\n ");
|
|
322
322
|
}).join("\n\n");
|
|
@@ -1177,7 +1177,7 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
|
|
|
1177
1177
|
]);
|
|
1178
1178
|
logWithPrefix(
|
|
1179
1179
|
[
|
|
1180
|
-
`${action === "bypass" ? "Warning:" : "Error:"} Request was not handled and was ${action === "bypass" ?
|
|
1180
|
+
`${action === "bypass" ? "Warning:" : "Error:"} Request was not handled and was ${action === "bypass" ? color2.yellow("bypassed") : color2.red("rejected")}.
|
|
1181
1181
|
|
|
1182
1182
|
`,
|
|
1183
1183
|
`${request.method} ${request.url}`,
|