msw 0.27.0 → 0.28.1

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 CHANGED
@@ -95,12 +95,12 @@ Performing a `GET https://github.com/octocat` request in your application will r
95
95
 
96
96
  ## Node
97
97
 
98
- - [Learn more about the NodeJS integration](https://mswjs.io/docs/getting-started/integrate/node)
98
+ - [Learn more about the Node.js integration](https://mswjs.io/docs/getting-started/integrate/node)
99
99
  - [`setupServer` API](https://mswjs.io/docs/api/setup-server)
100
100
 
101
101
  ### How does it work?
102
102
 
103
- Although Service Worker is a browser-specific API, this library allows to reuse the same mock definition to have API mocking in NodeJS through augmenting native request issuing modules.
103
+ Although Service Worker is a browser-specific API, this library allows to reuse the same mock definition to have API mocking in Node.js through augmenting native request issuing modules.
104
104
 
105
105
  ### How is it different?
106
106
 
@@ -1,11 +1,4 @@
1
- import { c as stringToHeaders, j as jsonParse, l as listToHeaders, H as Headers, s as status, a as set, d as delay, f as fetch } from './fetch-deps.js';
2
-
3
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
-
5
- function createCommonjsModule(fn) {
6
- var module = { exports: {} };
7
- return fn(module, module.exports), module.exports;
8
- }
1
+ import { c as createCommonjsModule, a as commonjsGlobal, l as lib, j as jsonParse, s as status, b as set, d as delay, f as fetch } from './fetch-deps.js';
9
2
 
10
3
  /*! *****************************************************************************
11
4
  Copyright (c) Microsoft Corporation.
@@ -1427,12 +1420,12 @@ function getTimestamp() {
1427
1420
  * Formats a mocked request for introspection in browser's console.
1428
1421
  */
1429
1422
  function prepareRequest(request) {
1430
- return Object.assign(Object.assign({}, request), { headers: request.headers.getAllHeaders() });
1423
+ return Object.assign(Object.assign({}, request), { headers: request.headers.all() });
1431
1424
  }
1432
1425
 
1433
1426
  function parseContentHeaders(headersString) {
1434
1427
  var _a, _b;
1435
- const headers = stringToHeaders(headersString);
1428
+ const headers = lib.stringToHeaders(headersString);
1436
1429
  const contentType = headers.get('content-type') || 'text/plain';
1437
1430
  const disposition = headers.get('content-disposition');
1438
1431
  if (!disposition) {
@@ -1460,7 +1453,7 @@ function parseMultipartData(data, headers) {
1460
1453
  if (!contentType) {
1461
1454
  return undefined;
1462
1455
  }
1463
- const [, ...directives] = contentType.split('; ');
1456
+ const [, ...directives] = contentType.split(/; */);
1464
1457
  const boundary = directives
1465
1458
  .filter((d) => d.startsWith('boundary='))
1466
1459
  .map((s) => s.replace(/^boundary=/, ''))[0];
@@ -1531,7 +1524,7 @@ function parseBody(body, headers) {
1531
1524
  * Formats a mocked response for introspection in browser's console.
1532
1525
  */
1533
1526
  function prepareResponse(res) {
1534
- const responseHeaders = listToHeaders(res.headers);
1527
+ const responseHeaders = lib.listToHeaders(res.headers);
1535
1528
  return Object.assign(Object.assign({}, res), {
1536
1529
  // Parse a response JSON body for preview in the logs
1537
1530
  body: parseBody(res.body, responseHeaders) });
@@ -1678,7 +1671,7 @@ const defaultResponseTransformers = [];
1678
1671
  function createResponseComposition(responseOverrides, defaultTransformers = defaultResponseTransformers) {
1679
1672
  return (...transformers) => __awaiter(this, void 0, void 0, function* () {
1680
1673
  const initialResponse = Object.assign({}, defaultResponse, {
1681
- headers: new Headers({
1674
+ headers: new lib.Headers({
1682
1675
  'x-powered-by': 'msw',
1683
1676
  }),
1684
1677
  }, responseOverrides);
@@ -1703,7 +1696,9 @@ const response = Object.assign(createResponseComposition(), {
1703
1696
  * Return the stack trace frame of a function's invocation.
1704
1697
  */
1705
1698
  function getCallFrame() {
1706
- const frames = new Error().stack.split('\n');
1699
+ // In <IE11, new Error may return an undefined stack
1700
+ const stack = (new Error().stack || '');
1701
+ const frames = stack.split('\n');
1707
1702
  // Get the first frame that doesn't reference the library's internal trace.
1708
1703
  // Assume that frame is the invocation frame.
1709
1704
  const ignoreFrameRegExp = /(node_modules)?[\/\\]lib[\/\\](umd|esm|iief|cjs)[\/\\]|^[^\/\\]*$/;
@@ -1786,4 +1781,4 @@ class RequestHandler {
1786
1781
  }
1787
1782
  }
1788
1783
 
1789
- export { NetworkError as N, RequestHandler as R, __awaiter as _, commonjsGlobal as a, createResponseComposition as b, createCommonjsModule as c, defaultResponse as d, defaultContext as e, compose as f, getPublicUrlFromRequest as g, getUrlByMask as h, prepareRequest as i, prepareResponse as j, getTimestamp as k, getStatusCodeColor as l, matchRequestUrl as m, __rest as n, parseBody as p, response as r };
1784
+ export { NetworkError as N, RequestHandler as R, __awaiter as _, defaultContext as a, compose as b, createResponseComposition as c, defaultResponse as d, getUrlByMask as e, prepareRequest as f, getPublicUrlFromRequest as g, prepareResponse as h, getTimestamp as i, getStatusCodeColor as j, __rest as k, matchRequestUrl as m, parseBody as p, response as r };
@@ -1,4 +1,4 @@
1
- import { j as jsonParse, b as json } from './fetch-deps.js';
1
+ import { j as jsonParse, e as json } from './fetch-deps.js';
2
2
 
3
3
  /**
4
4
  * Determines if the given value is an object.