msw-fetch-mock 0.3.1 → 0.3.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/dist/browser.cjs +5 -5
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +4 -4
- package/dist/{chunk-ATXIIOZA.js → chunk-3RAWYKAG.js} +79 -68
- package/dist/{chunk-D26SJTTI.js → chunk-IOGQ34QL.js} +3 -3
- package/dist/{chunk-43CWIVXO.cjs → chunk-N6B7UP6B.cjs} +79 -68
- package/dist/{chunk-A56K5DPD.cjs → chunk-PJU5FUNI.cjs} +5 -5
- package/dist/{chunk-KSDUQENI.js → chunk-PUVZ7LB4.js} +4 -4
- package/dist/{chunk-HYRDB2FH.cjs → chunk-QKIKWNFZ.cjs} +3 -3
- package/dist/{fetch-mock-BNke4Oik.d.cts → fetch-mock-DhiqmHdF.d.cts} +2 -2
- package/dist/{fetch-mock-BNke4Oik.d.ts → fetch-mock-DhiqmHdF.d.ts} +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/legacy.cjs +5 -5
- package/dist/legacy.d.cts +2 -2
- package/dist/legacy.d.ts +2 -2
- package/dist/legacy.js +1 -1
- package/dist/node.cjs +4 -4
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/package.json +1 -1
package/dist/browser.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQKIKWNFZcjs = require('./chunk-QKIKWNFZ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkN6B7UP6Bcjs = require('./chunk-N6B7UP6B.cjs');
|
|
9
9
|
|
|
10
10
|
// src/browser-adapter.ts
|
|
11
11
|
var BrowserMswAdapter = class {
|
|
@@ -30,9 +30,9 @@ var BrowserMswAdapter = class {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
// src/browser.ts
|
|
33
|
-
|
|
33
|
+
_chunkN6B7UP6Bcjs.FetchMock._handlerFactory = _chunkQKIKWNFZcjs.httpHandlerFactory;
|
|
34
34
|
function createFetchMock(worker) {
|
|
35
|
-
return new (0,
|
|
35
|
+
return new (0, _chunkN6B7UP6Bcjs.FetchMock)(new BrowserMswAdapter(worker));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
|
|
@@ -40,4 +40,4 @@ function createFetchMock(worker) {
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
exports.BrowserMswAdapter = BrowserMswAdapter; exports.FetchMock =
|
|
43
|
+
exports.BrowserMswAdapter = BrowserMswAdapter; exports.FetchMock = _chunkN6B7UP6Bcjs.FetchMock; exports.MockCallHistory = _chunkN6B7UP6Bcjs.MockCallHistory; exports.MockCallHistoryLog = _chunkN6B7UP6Bcjs.MockCallHistoryLog; exports.createFetchMock = createFetchMock;
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MswAdapter, S as SetupWorkerLike, R as ResolvedActivateOptions, F as FetchMock } from './fetch-mock-
|
|
2
|
-
export { A as ActivateOptions, C as CallHistoryFilterCriteria, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, O as OnUnhandledRequest, P as PendingInterceptor, g as ReplyOptions } from './fetch-mock-
|
|
1
|
+
import { M as MswAdapter, S as SetupWorkerLike, R as ResolvedActivateOptions, F as FetchMock } from './fetch-mock-DhiqmHdF.cjs';
|
|
2
|
+
export { A as ActivateOptions, C as CallHistoryFilterCriteria, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, O as OnUnhandledRequest, P as PendingInterceptor, g as ReplyOptions } from './fetch-mock-DhiqmHdF.cjs';
|
|
3
3
|
|
|
4
4
|
declare class BrowserMswAdapter implements MswAdapter {
|
|
5
5
|
private readonly worker;
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MswAdapter, S as SetupWorkerLike, R as ResolvedActivateOptions, F as FetchMock } from './fetch-mock-
|
|
2
|
-
export { A as ActivateOptions, C as CallHistoryFilterCriteria, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, O as OnUnhandledRequest, P as PendingInterceptor, g as ReplyOptions } from './fetch-mock-
|
|
1
|
+
import { M as MswAdapter, S as SetupWorkerLike, R as ResolvedActivateOptions, F as FetchMock } from './fetch-mock-DhiqmHdF.js';
|
|
2
|
+
export { A as ActivateOptions, C as CallHistoryFilterCriteria, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, O as OnUnhandledRequest, P as PendingInterceptor, g as ReplyOptions } from './fetch-mock-DhiqmHdF.js';
|
|
3
3
|
|
|
4
4
|
declare class BrowserMswAdapter implements MswAdapter {
|
|
5
5
|
private readonly worker;
|
package/dist/browser.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
httpHandlerFactory
|
|
3
|
+
} from "./chunk-IOGQ34QL.js";
|
|
4
4
|
import {
|
|
5
5
|
FetchMock,
|
|
6
6
|
MockCallHistory,
|
|
7
7
|
MockCallHistoryLog
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-3RAWYKAG.js";
|
|
9
9
|
|
|
10
10
|
// src/browser-adapter.ts
|
|
11
11
|
var BrowserMswAdapter = class {
|
|
@@ -30,7 +30,7 @@ var BrowserMswAdapter = class {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
// src/browser.ts
|
|
33
|
-
FetchMock._handlerFactory =
|
|
33
|
+
FetchMock._handlerFactory = httpHandlerFactory;
|
|
34
34
|
function createFetchMock(worker) {
|
|
35
35
|
return new FetchMock(new BrowserMswAdapter(worker));
|
|
36
36
|
}
|
|
@@ -375,28 +375,23 @@ ${descriptions.join("\n")}`);
|
|
|
375
375
|
}
|
|
376
376
|
return /.*/;
|
|
377
377
|
}
|
|
378
|
-
|
|
379
|
-
if (typeof origin === "string")
|
|
378
|
+
matchOriginAndPath(request, origin, originStr, path) {
|
|
379
|
+
if (typeof origin === "string") {
|
|
380
|
+
return matchPath(request, originStr, path);
|
|
381
|
+
}
|
|
380
382
|
const url = new URL(request.url);
|
|
381
|
-
if (origin instanceof RegExp
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (typeof path === "string") {
|
|
387
|
-
const url2 = new URL(request.url);
|
|
388
|
-
return url2.pathname === path || url2.pathname.endsWith(path);
|
|
389
|
-
}
|
|
390
|
-
const url = new URL(request.url);
|
|
391
|
-
const fullPath = url.pathname + url.search;
|
|
392
|
-
return matchesValue(fullPath, path);
|
|
383
|
+
if (origin instanceof RegExp ? !origin.test(url.origin) : !origin(url.origin)) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
if (typeof path === "string") {
|
|
387
|
+
return url.pathname === path || url.pathname.endsWith(path);
|
|
393
388
|
}
|
|
394
|
-
|
|
389
|
+
const fullPath = url.pathname + url.search;
|
|
390
|
+
return matchesValue(fullPath, path);
|
|
395
391
|
}
|
|
396
392
|
async matchAndConsume(request, pending, origin, originStr, options) {
|
|
397
393
|
if (!pending.persist && pending.timesInvoked >= pending.times) return;
|
|
398
|
-
if (!this.
|
|
399
|
-
if (!this.matchPathForOrigin(request, origin, originStr, options.path)) return;
|
|
394
|
+
if (!this.matchOriginAndPath(request, origin, originStr, options.path)) return;
|
|
400
395
|
if (!matchQuery(request, options.query)) return;
|
|
401
396
|
if (!matchHeaders(request, options.headers)) return;
|
|
402
397
|
const bodyText = await request.text() || null;
|
|
@@ -416,6 +411,16 @@ ${descriptions.join("\n")}`);
|
|
|
416
411
|
this.mswHandlers.set(pending, handler);
|
|
417
412
|
this.adapter.use(handler);
|
|
418
413
|
}
|
|
414
|
+
createMatchingHandler(pending, origin, originStr, options, delayRef, respond) {
|
|
415
|
+
return async (request) => {
|
|
416
|
+
const bodyText = await this.matchAndConsume(request, pending, origin, originStr, options);
|
|
417
|
+
if (bodyText === void 0) return;
|
|
418
|
+
if (delayRef.ms > 0) {
|
|
419
|
+
await new Promise((resolve) => setTimeout(resolve, delayRef.ms));
|
|
420
|
+
}
|
|
421
|
+
return respond(bodyText);
|
|
422
|
+
};
|
|
423
|
+
}
|
|
419
424
|
buildChain(pending, delayRef, contentLengthRef) {
|
|
420
425
|
return {
|
|
421
426
|
times(n) {
|
|
@@ -457,74 +462,80 @@ ${descriptions.join("\n")}`);
|
|
|
457
462
|
const contentLengthRef = { enabled: false };
|
|
458
463
|
if (typeof statusOrCallback === "function") {
|
|
459
464
|
const callback = statusOrCallback;
|
|
460
|
-
this.registerHandler(
|
|
461
|
-
|
|
462
|
-
|
|
465
|
+
this.registerHandler(
|
|
466
|
+
pending,
|
|
467
|
+
method,
|
|
468
|
+
urlPattern,
|
|
469
|
+
this.createMatchingHandler(
|
|
463
470
|
pending,
|
|
464
471
|
origin,
|
|
465
472
|
originStr,
|
|
466
|
-
options
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
});
|
|
473
|
+
options,
|
|
474
|
+
delayRef,
|
|
475
|
+
async (bodyText) => {
|
|
476
|
+
const result = await callback({ body: bodyText });
|
|
477
|
+
return this.buildResponse(
|
|
478
|
+
result.statusCode,
|
|
479
|
+
result.data,
|
|
480
|
+
result.responseOptions,
|
|
481
|
+
this._defaultReplyHeaders,
|
|
482
|
+
contentLengthRef.enabled
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
)
|
|
486
|
+
);
|
|
481
487
|
} else {
|
|
482
488
|
const status = statusOrCallback;
|
|
483
|
-
this.registerHandler(
|
|
484
|
-
|
|
485
|
-
|
|
489
|
+
this.registerHandler(
|
|
490
|
+
pending,
|
|
491
|
+
method,
|
|
492
|
+
urlPattern,
|
|
493
|
+
this.createMatchingHandler(
|
|
486
494
|
pending,
|
|
487
495
|
origin,
|
|
488
496
|
originStr,
|
|
489
|
-
options
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
});
|
|
497
|
+
options,
|
|
498
|
+
delayRef,
|
|
499
|
+
async (bodyText) => {
|
|
500
|
+
let responseBody;
|
|
501
|
+
if (typeof bodyOrCallback === "function") {
|
|
502
|
+
responseBody = await bodyOrCallback({
|
|
503
|
+
body: bodyText
|
|
504
|
+
});
|
|
505
|
+
} else {
|
|
506
|
+
responseBody = bodyOrCallback;
|
|
507
|
+
}
|
|
508
|
+
return this.buildResponse(
|
|
509
|
+
status,
|
|
510
|
+
responseBody,
|
|
511
|
+
replyOptions,
|
|
512
|
+
this._defaultReplyHeaders,
|
|
513
|
+
contentLengthRef.enabled
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
)
|
|
517
|
+
);
|
|
511
518
|
}
|
|
512
519
|
return this.buildChain(pending, delayRef, contentLengthRef);
|
|
513
520
|
},
|
|
514
521
|
replyWithError: () => {
|
|
515
522
|
const delayRef = { ms: 0 };
|
|
516
523
|
const contentLengthRef = { enabled: false };
|
|
517
|
-
this.registerHandler(
|
|
518
|
-
|
|
519
|
-
|
|
524
|
+
this.registerHandler(
|
|
525
|
+
pending,
|
|
526
|
+
method,
|
|
527
|
+
urlPattern,
|
|
528
|
+
this.createMatchingHandler(
|
|
520
529
|
pending,
|
|
521
530
|
origin,
|
|
522
531
|
originStr,
|
|
523
|
-
options
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
532
|
+
options,
|
|
533
|
+
delayRef,
|
|
534
|
+
async () => {
|
|
535
|
+
return this.handlerFactory.buildErrorResponse();
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
);
|
|
528
539
|
return this.buildChain(pending, delayRef, contentLengthRef);
|
|
529
540
|
}
|
|
530
541
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/http-handler-factory.ts
|
|
2
2
|
import { http, HttpResponse } from "msw";
|
|
3
3
|
var methods = {
|
|
4
4
|
GET: http.get,
|
|
@@ -7,7 +7,7 @@ var methods = {
|
|
|
7
7
|
DELETE: http.delete,
|
|
8
8
|
PATCH: http.patch
|
|
9
9
|
};
|
|
10
|
-
var
|
|
10
|
+
var httpHandlerFactory = {
|
|
11
11
|
createHandler(method, urlPattern, handlerFn) {
|
|
12
12
|
return methods[method](urlPattern, async ({ request }) => handlerFn(request));
|
|
13
13
|
},
|
|
@@ -23,5 +23,5 @@ var v2HandlerFactory = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export {
|
|
26
|
-
|
|
26
|
+
httpHandlerFactory
|
|
27
27
|
};
|
|
@@ -375,28 +375,23 @@ ${descriptions.join("\n")}`);
|
|
|
375
375
|
}
|
|
376
376
|
return /.*/;
|
|
377
377
|
}
|
|
378
|
-
|
|
379
|
-
if (typeof origin === "string")
|
|
378
|
+
matchOriginAndPath(request, origin, originStr, path) {
|
|
379
|
+
if (typeof origin === "string") {
|
|
380
|
+
return matchPath(request, originStr, path);
|
|
381
|
+
}
|
|
380
382
|
const url = new URL(request.url);
|
|
381
|
-
if (origin instanceof RegExp
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (typeof path === "string") {
|
|
387
|
-
const url2 = new URL(request.url);
|
|
388
|
-
return url2.pathname === path || url2.pathname.endsWith(path);
|
|
389
|
-
}
|
|
390
|
-
const url = new URL(request.url);
|
|
391
|
-
const fullPath = url.pathname + url.search;
|
|
392
|
-
return matchesValue(fullPath, path);
|
|
383
|
+
if (origin instanceof RegExp ? !origin.test(url.origin) : !origin(url.origin)) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
if (typeof path === "string") {
|
|
387
|
+
return url.pathname === path || url.pathname.endsWith(path);
|
|
393
388
|
}
|
|
394
|
-
|
|
389
|
+
const fullPath = url.pathname + url.search;
|
|
390
|
+
return matchesValue(fullPath, path);
|
|
395
391
|
}
|
|
396
392
|
async matchAndConsume(request, pending, origin, originStr, options) {
|
|
397
393
|
if (!pending.persist && pending.timesInvoked >= pending.times) return;
|
|
398
|
-
if (!this.
|
|
399
|
-
if (!this.matchPathForOrigin(request, origin, originStr, options.path)) return;
|
|
394
|
+
if (!this.matchOriginAndPath(request, origin, originStr, options.path)) return;
|
|
400
395
|
if (!matchQuery(request, options.query)) return;
|
|
401
396
|
if (!matchHeaders(request, options.headers)) return;
|
|
402
397
|
const bodyText = await request.text() || null;
|
|
@@ -416,6 +411,16 @@ ${descriptions.join("\n")}`);
|
|
|
416
411
|
this.mswHandlers.set(pending, handler);
|
|
417
412
|
this.adapter.use(handler);
|
|
418
413
|
}
|
|
414
|
+
createMatchingHandler(pending, origin, originStr, options, delayRef, respond) {
|
|
415
|
+
return async (request) => {
|
|
416
|
+
const bodyText = await this.matchAndConsume(request, pending, origin, originStr, options);
|
|
417
|
+
if (bodyText === void 0) return;
|
|
418
|
+
if (delayRef.ms > 0) {
|
|
419
|
+
await new Promise((resolve) => setTimeout(resolve, delayRef.ms));
|
|
420
|
+
}
|
|
421
|
+
return respond(bodyText);
|
|
422
|
+
};
|
|
423
|
+
}
|
|
419
424
|
buildChain(pending, delayRef, contentLengthRef) {
|
|
420
425
|
return {
|
|
421
426
|
times(n) {
|
|
@@ -457,74 +462,80 @@ ${descriptions.join("\n")}`);
|
|
|
457
462
|
const contentLengthRef = { enabled: false };
|
|
458
463
|
if (typeof statusOrCallback === "function") {
|
|
459
464
|
const callback = statusOrCallback;
|
|
460
|
-
this.registerHandler(
|
|
461
|
-
|
|
462
|
-
|
|
465
|
+
this.registerHandler(
|
|
466
|
+
pending,
|
|
467
|
+
method,
|
|
468
|
+
urlPattern,
|
|
469
|
+
this.createMatchingHandler(
|
|
463
470
|
pending,
|
|
464
471
|
origin,
|
|
465
472
|
originStr,
|
|
466
|
-
options
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
});
|
|
473
|
+
options,
|
|
474
|
+
delayRef,
|
|
475
|
+
async (bodyText) => {
|
|
476
|
+
const result = await callback({ body: bodyText });
|
|
477
|
+
return this.buildResponse(
|
|
478
|
+
result.statusCode,
|
|
479
|
+
result.data,
|
|
480
|
+
result.responseOptions,
|
|
481
|
+
this._defaultReplyHeaders,
|
|
482
|
+
contentLengthRef.enabled
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
)
|
|
486
|
+
);
|
|
481
487
|
} else {
|
|
482
488
|
const status = statusOrCallback;
|
|
483
|
-
this.registerHandler(
|
|
484
|
-
|
|
485
|
-
|
|
489
|
+
this.registerHandler(
|
|
490
|
+
pending,
|
|
491
|
+
method,
|
|
492
|
+
urlPattern,
|
|
493
|
+
this.createMatchingHandler(
|
|
486
494
|
pending,
|
|
487
495
|
origin,
|
|
488
496
|
originStr,
|
|
489
|
-
options
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
});
|
|
497
|
+
options,
|
|
498
|
+
delayRef,
|
|
499
|
+
async (bodyText) => {
|
|
500
|
+
let responseBody;
|
|
501
|
+
if (typeof bodyOrCallback === "function") {
|
|
502
|
+
responseBody = await bodyOrCallback({
|
|
503
|
+
body: bodyText
|
|
504
|
+
});
|
|
505
|
+
} else {
|
|
506
|
+
responseBody = bodyOrCallback;
|
|
507
|
+
}
|
|
508
|
+
return this.buildResponse(
|
|
509
|
+
status,
|
|
510
|
+
responseBody,
|
|
511
|
+
replyOptions,
|
|
512
|
+
this._defaultReplyHeaders,
|
|
513
|
+
contentLengthRef.enabled
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
)
|
|
517
|
+
);
|
|
511
518
|
}
|
|
512
519
|
return this.buildChain(pending, delayRef, contentLengthRef);
|
|
513
520
|
},
|
|
514
521
|
replyWithError: () => {
|
|
515
522
|
const delayRef = { ms: 0 };
|
|
516
523
|
const contentLengthRef = { enabled: false };
|
|
517
|
-
this.registerHandler(
|
|
518
|
-
|
|
519
|
-
|
|
524
|
+
this.registerHandler(
|
|
525
|
+
pending,
|
|
526
|
+
method,
|
|
527
|
+
urlPattern,
|
|
528
|
+
this.createMatchingHandler(
|
|
520
529
|
pending,
|
|
521
530
|
origin,
|
|
522
531
|
originStr,
|
|
523
|
-
options
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
532
|
+
options,
|
|
533
|
+
delayRef,
|
|
534
|
+
async () => {
|
|
535
|
+
return this.handlerFactory.buildErrorResponse();
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
);
|
|
528
539
|
return this.buildChain(pending, delayRef, contentLengthRef);
|
|
529
540
|
}
|
|
530
541
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkQKIKWNFZcjs = require('./chunk-QKIKWNFZ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkN6B7UP6Bcjs = require('./chunk-N6B7UP6B.cjs');
|
|
7
7
|
|
|
8
8
|
// src/node-adapter.ts
|
|
9
9
|
var _node = require('msw/node');
|
|
@@ -44,10 +44,10 @@ var NodeMswAdapter = class {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// src/node.ts
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
_chunkN6B7UP6Bcjs.FetchMock._defaultAdapterFactory = () => new NodeMswAdapter();
|
|
48
|
+
_chunkN6B7UP6Bcjs.FetchMock._handlerFactory = _chunkQKIKWNFZcjs.httpHandlerFactory;
|
|
49
49
|
function createFetchMock(server) {
|
|
50
|
-
return new (0,
|
|
50
|
+
return new (0, _chunkN6B7UP6Bcjs.FetchMock)(new NodeMswAdapter(server));
|
|
51
51
|
}
|
|
52
52
|
var fetchMock = createFetchMock();
|
|
53
53
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
httpHandlerFactory
|
|
3
|
+
} from "./chunk-IOGQ34QL.js";
|
|
4
4
|
import {
|
|
5
5
|
FetchMock
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3RAWYKAG.js";
|
|
7
7
|
|
|
8
8
|
// src/node-adapter.ts
|
|
9
9
|
import { setupServer } from "msw/node";
|
|
@@ -45,7 +45,7 @@ var NodeMswAdapter = class {
|
|
|
45
45
|
|
|
46
46
|
// src/node.ts
|
|
47
47
|
FetchMock._defaultAdapterFactory = () => new NodeMswAdapter();
|
|
48
|
-
FetchMock._handlerFactory =
|
|
48
|
+
FetchMock._handlerFactory = httpHandlerFactory;
|
|
49
49
|
function createFetchMock(server) {
|
|
50
50
|
return new FetchMock(new NodeMswAdapter(server));
|
|
51
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/http-handler-factory.ts
|
|
2
2
|
var _msw = require('msw');
|
|
3
3
|
var methods = {
|
|
4
4
|
GET: _msw.http.get,
|
|
@@ -7,7 +7,7 @@ var methods = {
|
|
|
7
7
|
DELETE: _msw.http.delete,
|
|
8
8
|
PATCH: _msw.http.patch
|
|
9
9
|
};
|
|
10
|
-
var
|
|
10
|
+
var httpHandlerFactory = {
|
|
11
11
|
createHandler(method, urlPattern, handlerFn) {
|
|
12
12
|
return methods[method](urlPattern, async ({ request }) => handlerFn(request));
|
|
13
13
|
},
|
|
@@ -24,4 +24,4 @@ var v2HandlerFactory = {
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
exports.
|
|
27
|
+
exports.httpHandlerFactory = httpHandlerFactory;
|
|
@@ -188,10 +188,10 @@ declare class FetchMock {
|
|
|
188
188
|
assertNoPendingInterceptors(): void;
|
|
189
189
|
pendingInterceptors(): PendingInterceptor[];
|
|
190
190
|
private resolveUrlPattern;
|
|
191
|
-
private
|
|
192
|
-
private matchPathForOrigin;
|
|
191
|
+
private matchOriginAndPath;
|
|
193
192
|
private matchAndConsume;
|
|
194
193
|
private registerHandler;
|
|
194
|
+
private createMatchingHandler;
|
|
195
195
|
private buildChain;
|
|
196
196
|
get(origin: string | RegExp | ((origin: string) => boolean)): MockPool;
|
|
197
197
|
}
|
|
@@ -188,10 +188,10 @@ declare class FetchMock {
|
|
|
188
188
|
assertNoPendingInterceptors(): void;
|
|
189
189
|
pendingInterceptors(): PendingInterceptor[];
|
|
190
190
|
private resolveUrlPattern;
|
|
191
|
-
private
|
|
192
|
-
private matchPathForOrigin;
|
|
191
|
+
private matchOriginAndPath;
|
|
193
192
|
private matchAndConsume;
|
|
194
193
|
private registerHandler;
|
|
194
|
+
private createMatchingHandler;
|
|
195
195
|
private buildChain;
|
|
196
196
|
get(origin: string | RegExp | ((origin: string) => boolean)): MockPool;
|
|
197
197
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('./chunk-
|
|
5
|
+
var _chunkPJU5FUNIcjs = require('./chunk-PJU5FUNI.cjs');
|
|
6
|
+
require('./chunk-QKIKWNFZ.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkN6B7UP6Bcjs = require('./chunk-N6B7UP6B.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -16,4 +16,4 @@ var _chunk43CWIVXOcjs = require('./chunk-43CWIVXO.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
exports.FetchMock =
|
|
19
|
+
exports.FetchMock = _chunkN6B7UP6Bcjs.FetchMock; exports.MockCallHistory = _chunkN6B7UP6Bcjs.MockCallHistory; exports.MockCallHistoryLog = _chunkN6B7UP6Bcjs.MockCallHistoryLog; exports.NodeMswAdapter = _chunkPJU5FUNIcjs.NodeMswAdapter; exports.createFetchMock = _chunkPJU5FUNIcjs.createFetchMock; exports.fetchMock = _chunkPJU5FUNIcjs.fetchMock;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NodeMswAdapter, createFetchMock, fetchMock } from './node.cjs';
|
|
2
|
-
export { A as ActivateOptions, C as CallHistoryFilterCriteria, F as FetchMock, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, M as MswAdapter, O as OnUnhandledRequest, P as PendingInterceptor, j as ReplyCallback, g as ReplyOptions, i as SetupServerLike, k as SingleReplyCallback, l as SingleReplyResult } from './fetch-mock-
|
|
2
|
+
export { A as ActivateOptions, C as CallHistoryFilterCriteria, F as FetchMock, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, M as MswAdapter, O as OnUnhandledRequest, P as PendingInterceptor, j as ReplyCallback, g as ReplyOptions, i as SetupServerLike, k as SingleReplyCallback, l as SingleReplyResult } from './fetch-mock-DhiqmHdF.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NodeMswAdapter, createFetchMock, fetchMock } from './node.js';
|
|
2
|
-
export { A as ActivateOptions, C as CallHistoryFilterCriteria, F as FetchMock, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, M as MswAdapter, O as OnUnhandledRequest, P as PendingInterceptor, j as ReplyCallback, g as ReplyOptions, i as SetupServerLike, k as SingleReplyCallback, l as SingleReplyResult } from './fetch-mock-
|
|
2
|
+
export { A as ActivateOptions, C as CallHistoryFilterCriteria, F as FetchMock, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, M as MswAdapter, O as OnUnhandledRequest, P as PendingInterceptor, j as ReplyCallback, g as ReplyOptions, i as SetupServerLike, k as SingleReplyCallback, l as SingleReplyResult } from './fetch-mock-DhiqmHdF.js';
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
NodeMswAdapter,
|
|
3
3
|
createFetchMock,
|
|
4
4
|
fetchMock
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-PUVZ7LB4.js";
|
|
6
|
+
import "./chunk-IOGQ34QL.js";
|
|
7
7
|
import {
|
|
8
8
|
FetchMock,
|
|
9
9
|
MockCallHistory,
|
|
10
10
|
MockCallHistoryLog
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-3RAWYKAG.js";
|
|
12
12
|
export {
|
|
13
13
|
FetchMock,
|
|
14
14
|
MockCallHistory,
|
package/dist/legacy.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkN6B7UP6Bcjs = require('./chunk-N6B7UP6B.cjs');
|
|
6
6
|
|
|
7
7
|
// src/legacy-handler-factory.ts
|
|
8
8
|
function createLegacyHandlerFactory(rest) {
|
|
@@ -56,11 +56,11 @@ function createLegacyHandlerFactory(rest) {
|
|
|
56
56
|
|
|
57
57
|
// src/legacy.ts
|
|
58
58
|
function createFetchMock(rest, server) {
|
|
59
|
-
|
|
59
|
+
_chunkN6B7UP6Bcjs.FetchMock._handlerFactory = createLegacyHandlerFactory(rest);
|
|
60
60
|
if (server) {
|
|
61
|
-
return new (0,
|
|
61
|
+
return new (0, _chunkN6B7UP6Bcjs.FetchMock)(server);
|
|
62
62
|
}
|
|
63
|
-
return new (0,
|
|
63
|
+
return new (0, _chunkN6B7UP6Bcjs.FetchMock)();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
|
|
@@ -68,4 +68,4 @@ function createFetchMock(rest, server) {
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
exports.FetchMock =
|
|
71
|
+
exports.FetchMock = _chunkN6B7UP6Bcjs.FetchMock; exports.MockCallHistory = _chunkN6B7UP6Bcjs.MockCallHistory; exports.MockCallHistoryLog = _chunkN6B7UP6Bcjs.MockCallHistoryLog; exports.createFetchMock = createFetchMock; exports.createLegacyHandlerFactory = createLegacyHandlerFactory;
|
package/dist/legacy.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as HttpMethod, H as HandlerFactory, i as SetupServerLike, F as FetchMock } from './fetch-mock-
|
|
2
|
-
export { A as ActivateOptions, C as CallHistoryFilterCriteria, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, M as MswAdapter, O as OnUnhandledRequest, P as PendingInterceptor, g as ReplyOptions } from './fetch-mock-
|
|
1
|
+
import { h as HttpMethod, H as HandlerFactory, i as SetupServerLike, F as FetchMock } from './fetch-mock-DhiqmHdF.cjs';
|
|
2
|
+
export { A as ActivateOptions, C as CallHistoryFilterCriteria, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, M as MswAdapter, O as OnUnhandledRequest, P as PendingInterceptor, g as ReplyOptions } from './fetch-mock-DhiqmHdF.cjs';
|
|
3
3
|
|
|
4
4
|
/** Duck-typed interface for MSW v1's `rest` API methods */
|
|
5
5
|
type LegacyRestMethod = (url: string | RegExp, resolver: (req: any, res: any, ctx: any) => any) => unknown;
|
package/dist/legacy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as HttpMethod, H as HandlerFactory, i as SetupServerLike, F as FetchMock } from './fetch-mock-
|
|
2
|
-
export { A as ActivateOptions, C as CallHistoryFilterCriteria, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, M as MswAdapter, O as OnUnhandledRequest, P as PendingInterceptor, g as ReplyOptions } from './fetch-mock-
|
|
1
|
+
import { h as HttpMethod, H as HandlerFactory, i as SetupServerLike, F as FetchMock } from './fetch-mock-DhiqmHdF.js';
|
|
2
|
+
export { A as ActivateOptions, C as CallHistoryFilterCriteria, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, M as MswAdapter, O as OnUnhandledRequest, P as PendingInterceptor, g as ReplyOptions } from './fetch-mock-DhiqmHdF.js';
|
|
3
3
|
|
|
4
4
|
/** Duck-typed interface for MSW v1's `rest` API methods */
|
|
5
5
|
type LegacyRestMethod = (url: string | RegExp, resolver: (req: any, res: any, ctx: any) => any) => unknown;
|
package/dist/legacy.js
CHANGED
package/dist/node.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('./chunk-
|
|
5
|
+
var _chunkPJU5FUNIcjs = require('./chunk-PJU5FUNI.cjs');
|
|
6
|
+
require('./chunk-QKIKWNFZ.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkN6B7UP6Bcjs = require('./chunk-N6B7UP6B.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -16,4 +16,4 @@ var _chunk43CWIVXOcjs = require('./chunk-43CWIVXO.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
exports.FetchMock =
|
|
19
|
+
exports.FetchMock = _chunkN6B7UP6Bcjs.FetchMock; exports.MockCallHistory = _chunkN6B7UP6Bcjs.MockCallHistory; exports.MockCallHistoryLog = _chunkN6B7UP6Bcjs.MockCallHistoryLog; exports.NodeMswAdapter = _chunkPJU5FUNIcjs.NodeMswAdapter; exports.createFetchMock = _chunkPJU5FUNIcjs.createFetchMock; exports.fetchMock = _chunkPJU5FUNIcjs.fetchMock;
|
package/dist/node.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MswAdapter, i as SetupServerLike, R as ResolvedActivateOptions, F as FetchMock } from './fetch-mock-
|
|
2
|
-
export { A as ActivateOptions, C as CallHistoryFilterCriteria, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, O as OnUnhandledRequest, P as PendingInterceptor, j as ReplyCallback, g as ReplyOptions, k as SingleReplyCallback, l as SingleReplyResult } from './fetch-mock-
|
|
1
|
+
import { M as MswAdapter, i as SetupServerLike, R as ResolvedActivateOptions, F as FetchMock } from './fetch-mock-DhiqmHdF.cjs';
|
|
2
|
+
export { A as ActivateOptions, C as CallHistoryFilterCriteria, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, O as OnUnhandledRequest, P as PendingInterceptor, j as ReplyCallback, g as ReplyOptions, k as SingleReplyCallback, l as SingleReplyResult } from './fetch-mock-DhiqmHdF.cjs';
|
|
3
3
|
|
|
4
4
|
declare class NodeMswAdapter implements MswAdapter {
|
|
5
5
|
private server;
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MswAdapter, i as SetupServerLike, R as ResolvedActivateOptions, F as FetchMock } from './fetch-mock-
|
|
2
|
-
export { A as ActivateOptions, C as CallHistoryFilterCriteria, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, O as OnUnhandledRequest, P as PendingInterceptor, j as ReplyCallback, g as ReplyOptions, k as SingleReplyCallback, l as SingleReplyResult } from './fetch-mock-
|
|
1
|
+
import { M as MswAdapter, i as SetupServerLike, R as ResolvedActivateOptions, F as FetchMock } from './fetch-mock-DhiqmHdF.js';
|
|
2
|
+
export { A as ActivateOptions, C as CallHistoryFilterCriteria, H as HandlerFactory, I as InterceptOptions, a as MockCallHistory, b as MockCallHistoryLog, c as MockCallHistoryLogData, d as MockInterceptor, e as MockPool, f as MockReplyChain, O as OnUnhandledRequest, P as PendingInterceptor, j as ReplyCallback, g as ReplyOptions, k as SingleReplyCallback, l as SingleReplyResult } from './fetch-mock-DhiqmHdF.js';
|
|
3
3
|
|
|
4
4
|
declare class NodeMswAdapter implements MswAdapter {
|
|
5
5
|
private server;
|
package/dist/node.js
CHANGED
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
NodeMswAdapter,
|
|
3
3
|
createFetchMock,
|
|
4
4
|
fetchMock
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-PUVZ7LB4.js";
|
|
6
|
+
import "./chunk-IOGQ34QL.js";
|
|
7
7
|
import {
|
|
8
8
|
FetchMock,
|
|
9
9
|
MockCallHistory,
|
|
10
10
|
MockCallHistoryLog
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-3RAWYKAG.js";
|
|
12
12
|
export {
|
|
13
13
|
FetchMock,
|
|
14
14
|
MockCallHistory,
|