@mswjs/interceptors 0.36.7 → 0.36.8

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.
Files changed (47) hide show
  1. package/lib/browser/{chunk-V6CPQFVJ.mjs → chunk-45ALW4JK.mjs} +2 -2
  2. package/lib/browser/{chunk-6YUX267Y.js → chunk-6CHFD3BW.js} +3 -3
  3. package/lib/browser/{chunk-TJ2ZCQ33.js → chunk-6QUU6UER.js} +3 -3
  4. package/lib/browser/{chunk-YV5F3DAI.mjs → chunk-DZYTPQEW.mjs} +2 -2
  5. package/lib/browser/{chunk-7Z3OOH2U.js → chunk-PFGO5BSM.js} +7 -1
  6. package/lib/browser/chunk-PFGO5BSM.js.map +1 -0
  7. package/lib/{node/chunk-7W52P3VX.mjs → browser/chunk-TX5GBTFY.mjs} +7 -1
  8. package/lib/browser/chunk-TX5GBTFY.mjs.map +1 -0
  9. package/lib/browser/interceptors/WebSocket/index.js +2 -2
  10. package/lib/browser/interceptors/WebSocket/index.mjs +1 -1
  11. package/lib/browser/interceptors/XMLHttpRequest/index.js +3 -3
  12. package/lib/browser/interceptors/XMLHttpRequest/index.mjs +2 -2
  13. package/lib/browser/interceptors/fetch/index.js +3 -3
  14. package/lib/browser/interceptors/fetch/index.mjs +2 -2
  15. package/lib/browser/presets/browser.js +5 -5
  16. package/lib/browser/presets/browser.mjs +3 -3
  17. package/lib/node/RemoteHttpInterceptor.js +3 -3
  18. package/lib/node/RemoteHttpInterceptor.mjs +2 -2
  19. package/lib/node/{chunk-KVQI7UNN.js → chunk-CR4RBHMG.js} +3 -3
  20. package/lib/node/{chunk-RNZHVDD2.mjs → chunk-EV33OS3A.mjs} +2 -2
  21. package/lib/node/{chunk-XR7ZDC5N.js → chunk-FLQK3CSL.js} +3 -3
  22. package/lib/node/{chunk-GXB3PZMC.mjs → chunk-GD7YWPFZ.mjs} +2 -2
  23. package/lib/node/{chunk-7Z3OOH2U.js → chunk-PFGO5BSM.js} +7 -1
  24. package/lib/node/chunk-PFGO5BSM.js.map +1 -0
  25. package/lib/{browser/chunk-7W52P3VX.mjs → node/chunk-TX5GBTFY.mjs} +7 -1
  26. package/lib/node/chunk-TX5GBTFY.mjs.map +1 -0
  27. package/lib/node/interceptors/XMLHttpRequest/index.js +3 -3
  28. package/lib/node/interceptors/XMLHttpRequest/index.mjs +2 -2
  29. package/lib/node/interceptors/fetch/index.js +3 -3
  30. package/lib/node/interceptors/fetch/index.mjs +2 -2
  31. package/lib/node/presets/node.js +5 -5
  32. package/lib/node/presets/node.mjs +3 -3
  33. package/package.json +1 -1
  34. package/src/utils/hasConfigurableGlobal.test.ts +24 -0
  35. package/src/utils/hasConfigurableGlobal.ts +14 -0
  36. package/lib/browser/chunk-7W52P3VX.mjs.map +0 -1
  37. package/lib/browser/chunk-7Z3OOH2U.js.map +0 -1
  38. package/lib/node/chunk-7W52P3VX.mjs.map +0 -1
  39. package/lib/node/chunk-7Z3OOH2U.js.map +0 -1
  40. /package/lib/browser/{chunk-V6CPQFVJ.mjs.map → chunk-45ALW4JK.mjs.map} +0 -0
  41. /package/lib/browser/{chunk-6YUX267Y.js.map → chunk-6CHFD3BW.js.map} +0 -0
  42. /package/lib/browser/{chunk-TJ2ZCQ33.js.map → chunk-6QUU6UER.js.map} +0 -0
  43. /package/lib/browser/{chunk-YV5F3DAI.mjs.map → chunk-DZYTPQEW.mjs.map} +0 -0
  44. /package/lib/node/{chunk-KVQI7UNN.js.map → chunk-CR4RBHMG.js.map} +0 -0
  45. /package/lib/node/{chunk-RNZHVDD2.mjs.map → chunk-EV33OS3A.mjs.map} +0 -0
  46. /package/lib/node/{chunk-XR7ZDC5N.js.map → chunk-FLQK3CSL.js.map} +0 -0
  47. /package/lib/node/{chunk-GXB3PZMC.mjs.map → chunk-GD7YWPFZ.mjs.map} +0 -0
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-XVPRNJO7.mjs";
14
14
  import {
15
15
  hasConfigurableGlobal
16
- } from "./chunk-7W52P3VX.mjs";
16
+ } from "./chunk-TX5GBTFY.mjs";
17
17
  import {
18
18
  INTERNAL_REQUEST_ID_HEADER_NAME,
19
19
  Interceptor,
@@ -840,4 +840,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
840
840
  export {
841
841
  XMLHttpRequestInterceptor
842
842
  };
843
- //# sourceMappingURL=chunk-V6CPQFVJ.mjs.map
843
+ //# sourceMappingURL=chunk-45ALW4JK.mjs.map
@@ -13,7 +13,7 @@ var _chunkFYSUKT3Fjs = require('./chunk-FYSUKT3F.js');
13
13
  var _chunk2CAGU4FTjs = require('./chunk-2CAGU4FT.js');
14
14
 
15
15
 
16
- var _chunk7Z3OOH2Ujs = require('./chunk-7Z3OOH2U.js');
16
+ var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
17
17
 
18
18
 
19
19
 
@@ -799,7 +799,7 @@ var _XMLHttpRequestInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
799
799
  super(_XMLHttpRequestInterceptor.interceptorSymbol);
800
800
  }
801
801
  checkEnvironment() {
802
- return _chunk7Z3OOH2Ujs.hasConfigurableGlobal.call(void 0, "XMLHttpRequest");
802
+ return _chunkPFGO5BSMjs.hasConfigurableGlobal.call(void 0, "XMLHttpRequest");
803
803
  }
804
804
  setup() {
805
805
  const logger = this.logger.extend("setup");
@@ -840,4 +840,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
840
840
 
841
841
 
842
842
  exports.XMLHttpRequestInterceptor = XMLHttpRequestInterceptor;
843
- //# sourceMappingURL=chunk-6YUX267Y.js.map
843
+ //# sourceMappingURL=chunk-6CHFD3BW.js.map
@@ -9,7 +9,7 @@ var _chunkFYSUKT3Fjs = require('./chunk-FYSUKT3F.js');
9
9
  var _chunk2CAGU4FTjs = require('./chunk-2CAGU4FT.js');
10
10
 
11
11
 
12
- var _chunk7Z3OOH2Ujs = require('./chunk-7Z3OOH2U.js');
12
+ var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
13
13
 
14
14
 
15
15
 
@@ -175,7 +175,7 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
175
175
  super(_FetchInterceptor.symbol);
176
176
  }
177
177
  checkEnvironment() {
178
- return _chunk7Z3OOH2Ujs.hasConfigurableGlobal.call(void 0, "fetch");
178
+ return _chunkPFGO5BSMjs.hasConfigurableGlobal.call(void 0, "fetch");
179
179
  }
180
180
  async setup() {
181
181
  const pureFetch = globalThis.fetch;
@@ -297,4 +297,4 @@ FetchInterceptor.symbol = Symbol("fetch");
297
297
 
298
298
 
299
299
  exports.FetchInterceptor = FetchInterceptor;
300
- //# sourceMappingURL=chunk-TJ2ZCQ33.js.map
300
+ //# sourceMappingURL=chunk-6QUU6UER.js.map
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-XVPRNJO7.mjs";
10
10
  import {
11
11
  hasConfigurableGlobal
12
- } from "./chunk-7W52P3VX.mjs";
12
+ } from "./chunk-TX5GBTFY.mjs";
13
13
  import {
14
14
  Interceptor,
15
15
  createRequestId
@@ -297,4 +297,4 @@ FetchInterceptor.symbol = Symbol("fetch");
297
297
  export {
298
298
  FetchInterceptor
299
299
  };
300
- //# sourceMappingURL=chunk-YV5F3DAI.mjs.map
300
+ //# sourceMappingURL=chunk-DZYTPQEW.mjs.map
@@ -4,6 +4,12 @@ function hasConfigurableGlobal(propertyName) {
4
4
  if (typeof descriptor === "undefined") {
5
5
  return false;
6
6
  }
7
+ if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") {
8
+ return false;
9
+ }
10
+ if (typeof descriptor.get === "undefined" && descriptor.value == null) {
11
+ return false;
12
+ }
7
13
  if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
8
14
  console.error(
9
15
  `[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`
@@ -16,4 +22,4 @@ function hasConfigurableGlobal(propertyName) {
16
22
 
17
23
 
18
24
  exports.hasConfigurableGlobal = hasConfigurableGlobal;
19
- //# sourceMappingURL=chunk-7Z3OOH2U.js.map
25
+ //# sourceMappingURL=chunk-PFGO5BSM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/hasConfigurableGlobal.ts"],"names":[],"mappings":";AAIO,SAAS,sBAAsB,cAA+B;AACnE,QAAM,aAAa,OAAO,yBAAyB,YAAY,YAAY;AAG3E,MAAI,OAAO,eAAe,aAAa;AACrC,WAAO;AAAA,EACT;AAGA,MACE,OAAO,WAAW,QAAQ,cAC1B,OAAO,WAAW,IAAI,MAAM,aAC5B;AACA,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,WAAW,QAAQ,eAAe,WAAW,SAAS,MAAM;AACrE,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,YAAQ;AAAA,MACN,mDAAmD;AAAA,IACrD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT","sourcesContent":["/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(propertyName: string): boolean {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName)\n\n // The property is not set at all.\n if (typeof descriptor === 'undefined') {\n return false\n }\n\n // The property is set to a getter that returns undefined.\n if (\n typeof descriptor.get === 'function' &&\n typeof descriptor.get() === 'undefined'\n ) {\n return false\n }\n\n // The property is set to a value equal to undefined.\n if (typeof descriptor.get === 'undefined' && descriptor.value == null) {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"]}
@@ -4,6 +4,12 @@ function hasConfigurableGlobal(propertyName) {
4
4
  if (typeof descriptor === "undefined") {
5
5
  return false;
6
6
  }
7
+ if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") {
8
+ return false;
9
+ }
10
+ if (typeof descriptor.get === "undefined" && descriptor.value == null) {
11
+ return false;
12
+ }
7
13
  if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
8
14
  console.error(
9
15
  `[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`
@@ -16,4 +22,4 @@ function hasConfigurableGlobal(propertyName) {
16
22
  export {
17
23
  hasConfigurableGlobal
18
24
  };
19
- //# sourceMappingURL=chunk-7W52P3VX.mjs.map
25
+ //# sourceMappingURL=chunk-TX5GBTFY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/hasConfigurableGlobal.ts"],"sourcesContent":["/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(propertyName: string): boolean {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName)\n\n // The property is not set at all.\n if (typeof descriptor === 'undefined') {\n return false\n }\n\n // The property is set to a getter that returns undefined.\n if (\n typeof descriptor.get === 'function' &&\n typeof descriptor.get() === 'undefined'\n ) {\n return false\n }\n\n // The property is set to a value equal to undefined.\n if (typeof descriptor.get === 'undefined' && descriptor.value == null) {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"],"mappings":";AAIO,SAAS,sBAAsB,cAA+B;AACnE,QAAM,aAAa,OAAO,yBAAyB,YAAY,YAAY;AAG3E,MAAI,OAAO,eAAe,aAAa;AACrC,WAAO;AAAA,EACT;AAGA,MACE,OAAO,WAAW,QAAQ,cAC1B,OAAO,WAAW,IAAI,MAAM,aAC5B;AACA,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,WAAW,QAAQ,eAAe,WAAW,SAAS,MAAM;AACrE,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,YAAQ;AAAA,MACN,mDAAmD;AAAA,IACrD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk7Z3OOH2Ujs = require('../../chunk-7Z3OOH2U.js');
3
+ var _chunkPFGO5BSMjs = require('../../chunk-PFGO5BSM.js');
4
4
 
5
5
 
6
6
 
@@ -617,7 +617,7 @@ var _WebSocketInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
617
617
  super(_WebSocketInterceptor.symbol);
618
618
  }
619
619
  checkEnvironment() {
620
- return _chunk7Z3OOH2Ujs.hasConfigurableGlobal.call(void 0, "WebSocket");
620
+ return _chunkPFGO5BSMjs.hasConfigurableGlobal.call(void 0, "WebSocket");
621
621
  }
622
622
  setup() {
623
623
  const originalWebSocketDescriptor = Object.getOwnPropertyDescriptor(
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  hasConfigurableGlobal
3
- } from "../../chunk-7W52P3VX.mjs";
3
+ } from "../../chunk-TX5GBTFY.mjs";
4
4
  import {
5
5
  Interceptor,
6
6
  createRequestId
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk6YUX267Yjs = require('../../chunk-6YUX267Y.js');
3
+ var _chunk6CHFD3BWjs = require('../../chunk-6CHFD3BW.js');
4
4
  require('../../chunk-LK6DILFK.js');
5
5
  require('../../chunk-FYSUKT3F.js');
6
6
  require('../../chunk-2CAGU4FT.js');
7
- require('../../chunk-7Z3OOH2U.js');
7
+ require('../../chunk-PFGO5BSM.js');
8
8
  require('../../chunk-TIPR373R.js');
9
9
 
10
10
 
11
- exports.XMLHttpRequestInterceptor = _chunk6YUX267Yjs.XMLHttpRequestInterceptor;
11
+ exports.XMLHttpRequestInterceptor = _chunk6CHFD3BWjs.XMLHttpRequestInterceptor;
12
12
  //# sourceMappingURL=index.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  XMLHttpRequestInterceptor
3
- } from "../../chunk-V6CPQFVJ.mjs";
3
+ } from "../../chunk-45ALW4JK.mjs";
4
4
  import "../../chunk-6HYIRFX2.mjs";
5
5
  import "../../chunk-THPGBWJQ.mjs";
6
6
  import "../../chunk-XVPRNJO7.mjs";
7
- import "../../chunk-7W52P3VX.mjs";
7
+ import "../../chunk-TX5GBTFY.mjs";
8
8
  import "../../chunk-QED3Q6Z2.mjs";
9
9
  export {
10
10
  XMLHttpRequestInterceptor
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkTJ2ZCQ33js = require('../../chunk-TJ2ZCQ33.js');
3
+ var _chunk6QUU6UERjs = require('../../chunk-6QUU6UER.js');
4
4
  require('../../chunk-FYSUKT3F.js');
5
5
  require('../../chunk-2CAGU4FT.js');
6
- require('../../chunk-7Z3OOH2U.js');
6
+ require('../../chunk-PFGO5BSM.js');
7
7
  require('../../chunk-TIPR373R.js');
8
8
 
9
9
 
10
- exports.FetchInterceptor = _chunkTJ2ZCQ33js.FetchInterceptor;
10
+ exports.FetchInterceptor = _chunk6QUU6UERjs.FetchInterceptor;
11
11
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  FetchInterceptor
3
- } from "../../chunk-YV5F3DAI.mjs";
3
+ } from "../../chunk-DZYTPQEW.mjs";
4
4
  import "../../chunk-THPGBWJQ.mjs";
5
5
  import "../../chunk-XVPRNJO7.mjs";
6
- import "../../chunk-7W52P3VX.mjs";
6
+ import "../../chunk-TX5GBTFY.mjs";
7
7
  import "../../chunk-QED3Q6Z2.mjs";
8
8
  export {
9
9
  FetchInterceptor
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk6YUX267Yjs = require('../chunk-6YUX267Y.js');
3
+ var _chunk6CHFD3BWjs = require('../chunk-6CHFD3BW.js');
4
4
  require('../chunk-LK6DILFK.js');
5
5
 
6
6
 
7
- var _chunkTJ2ZCQ33js = require('../chunk-TJ2ZCQ33.js');
7
+ var _chunk6QUU6UERjs = require('../chunk-6QUU6UER.js');
8
8
  require('../chunk-FYSUKT3F.js');
9
9
  require('../chunk-2CAGU4FT.js');
10
- require('../chunk-7Z3OOH2U.js');
10
+ require('../chunk-PFGO5BSM.js');
11
11
  require('../chunk-TIPR373R.js');
12
12
 
13
13
  // src/presets/browser.ts
14
14
  var browser_default = [
15
- new (0, _chunkTJ2ZCQ33js.FetchInterceptor)(),
16
- new (0, _chunk6YUX267Yjs.XMLHttpRequestInterceptor)()
15
+ new (0, _chunk6QUU6UERjs.FetchInterceptor)(),
16
+ new (0, _chunk6CHFD3BWjs.XMLHttpRequestInterceptor)()
17
17
  ];
18
18
 
19
19
 
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  XMLHttpRequestInterceptor
3
- } from "../chunk-V6CPQFVJ.mjs";
3
+ } from "../chunk-45ALW4JK.mjs";
4
4
  import "../chunk-6HYIRFX2.mjs";
5
5
  import {
6
6
  FetchInterceptor
7
- } from "../chunk-YV5F3DAI.mjs";
7
+ } from "../chunk-DZYTPQEW.mjs";
8
8
  import "../chunk-THPGBWJQ.mjs";
9
9
  import "../chunk-XVPRNJO7.mjs";
10
- import "../chunk-7W52P3VX.mjs";
10
+ import "../chunk-TX5GBTFY.mjs";
11
11
  import "../chunk-QED3Q6Z2.mjs";
12
12
 
13
13
  // src/presets/browser.ts
@@ -6,9 +6,9 @@ var _chunkPGTBKPWNjs = require('./chunk-PGTBKPWN.js');
6
6
  var _chunkFPLETXGAjs = require('./chunk-FPLETXGA.js');
7
7
 
8
8
 
9
- var _chunkXR7ZDC5Njs = require('./chunk-XR7ZDC5N.js');
9
+ var _chunkFLQK3CSLjs = require('./chunk-FLQK3CSL.js');
10
10
  require('./chunk-LK6DILFK.js');
11
- require('./chunk-7Z3OOH2U.js');
11
+ require('./chunk-PFGO5BSM.js');
12
12
  require('./chunk-IDEEMJ3F.js');
13
13
 
14
14
 
@@ -25,7 +25,7 @@ var RemoteHttpInterceptor = class extends _chunkPGTBKPWNjs.BatchInterceptor {
25
25
  name: "remote-interceptor",
26
26
  interceptors: [
27
27
  new (0, _chunkFPLETXGAjs.ClientRequestInterceptor)(),
28
- new (0, _chunkXR7ZDC5Njs.XMLHttpRequestInterceptor)()
28
+ new (0, _chunkFLQK3CSLjs.XMLHttpRequestInterceptor)()
29
29
  ]
30
30
  });
31
31
  }
@@ -6,9 +6,9 @@ import {
6
6
  } from "./chunk-MG3S53QP.mjs";
7
7
  import {
8
8
  XMLHttpRequestInterceptor
9
- } from "./chunk-RNZHVDD2.mjs";
9
+ } from "./chunk-EV33OS3A.mjs";
10
10
  import "./chunk-6HYIRFX2.mjs";
11
- import "./chunk-7W52P3VX.mjs";
11
+ import "./chunk-TX5GBTFY.mjs";
12
12
  import "./chunk-BZ3Y7YV5.mjs";
13
13
  import {
14
14
  RequestController,
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunk7Z3OOH2Ujs = require('./chunk-7Z3OOH2U.js');
3
+ var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
4
4
 
5
5
 
6
6
  var _chunkIDEEMJ3Fjs = require('./chunk-IDEEMJ3F.js');
@@ -190,7 +190,7 @@ var _FetchInterceptor = class extends _chunkAABH3XLQjs.Interceptor {
190
190
  super(_FetchInterceptor.symbol);
191
191
  }
192
192
  checkEnvironment() {
193
- return _chunk7Z3OOH2Ujs.hasConfigurableGlobal.call(void 0, "fetch");
193
+ return _chunkPFGO5BSMjs.hasConfigurableGlobal.call(void 0, "fetch");
194
194
  }
195
195
  async setup() {
196
196
  const pureFetch = globalThis.fetch;
@@ -312,4 +312,4 @@ FetchInterceptor.symbol = Symbol("fetch");
312
312
 
313
313
 
314
314
  exports.FetchInterceptor = FetchInterceptor;
315
- //# sourceMappingURL=chunk-KVQI7UNN.js.map
315
+ //# sourceMappingURL=chunk-CR4RBHMG.js.map
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-6HYIRFX2.mjs";
6
6
  import {
7
7
  hasConfigurableGlobal
8
- } from "./chunk-7W52P3VX.mjs";
8
+ } from "./chunk-TX5GBTFY.mjs";
9
9
  import {
10
10
  IS_PATCHED_MODULE
11
11
  } from "./chunk-BZ3Y7YV5.mjs";
@@ -840,4 +840,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
840
840
  export {
841
841
  XMLHttpRequestInterceptor
842
842
  };
843
- //# sourceMappingURL=chunk-RNZHVDD2.mjs.map
843
+ //# sourceMappingURL=chunk-EV33OS3A.mjs.map
@@ -5,7 +5,7 @@
5
5
  var _chunkLK6DILFKjs = require('./chunk-LK6DILFK.js');
6
6
 
7
7
 
8
- var _chunk7Z3OOH2Ujs = require('./chunk-7Z3OOH2U.js');
8
+ var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
9
9
 
10
10
 
11
11
  var _chunkIDEEMJ3Fjs = require('./chunk-IDEEMJ3F.js');
@@ -799,7 +799,7 @@ var _XMLHttpRequestInterceptor = class extends _chunkAABH3XLQjs.Interceptor {
799
799
  super(_XMLHttpRequestInterceptor.interceptorSymbol);
800
800
  }
801
801
  checkEnvironment() {
802
- return _chunk7Z3OOH2Ujs.hasConfigurableGlobal.call(void 0, "XMLHttpRequest");
802
+ return _chunkPFGO5BSMjs.hasConfigurableGlobal.call(void 0, "XMLHttpRequest");
803
803
  }
804
804
  setup() {
805
805
  const logger = this.logger.extend("setup");
@@ -840,4 +840,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
840
840
 
841
841
 
842
842
  exports.XMLHttpRequestInterceptor = XMLHttpRequestInterceptor;
843
- //# sourceMappingURL=chunk-XR7ZDC5N.js.map
843
+ //# sourceMappingURL=chunk-FLQK3CSL.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  hasConfigurableGlobal
3
- } from "./chunk-7W52P3VX.mjs";
3
+ } from "./chunk-TX5GBTFY.mjs";
4
4
  import {
5
5
  IS_PATCHED_MODULE
6
6
  } from "./chunk-BZ3Y7YV5.mjs";
@@ -312,4 +312,4 @@ FetchInterceptor.symbol = Symbol("fetch");
312
312
  export {
313
313
  FetchInterceptor
314
314
  };
315
- //# sourceMappingURL=chunk-GXB3PZMC.mjs.map
315
+ //# sourceMappingURL=chunk-GD7YWPFZ.mjs.map
@@ -4,6 +4,12 @@ function hasConfigurableGlobal(propertyName) {
4
4
  if (typeof descriptor === "undefined") {
5
5
  return false;
6
6
  }
7
+ if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") {
8
+ return false;
9
+ }
10
+ if (typeof descriptor.get === "undefined" && descriptor.value == null) {
11
+ return false;
12
+ }
7
13
  if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
8
14
  console.error(
9
15
  `[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`
@@ -16,4 +22,4 @@ function hasConfigurableGlobal(propertyName) {
16
22
 
17
23
 
18
24
  exports.hasConfigurableGlobal = hasConfigurableGlobal;
19
- //# sourceMappingURL=chunk-7Z3OOH2U.js.map
25
+ //# sourceMappingURL=chunk-PFGO5BSM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/hasConfigurableGlobal.ts"],"names":[],"mappings":";AAIO,SAAS,sBAAsB,cAA+B;AACnE,QAAM,aAAa,OAAO,yBAAyB,YAAY,YAAY;AAG3E,MAAI,OAAO,eAAe,aAAa;AACrC,WAAO;AAAA,EACT;AAGA,MACE,OAAO,WAAW,QAAQ,cAC1B,OAAO,WAAW,IAAI,MAAM,aAC5B;AACA,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,WAAW,QAAQ,eAAe,WAAW,SAAS,MAAM;AACrE,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,YAAQ;AAAA,MACN,mDAAmD;AAAA,IACrD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT","sourcesContent":["/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(propertyName: string): boolean {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName)\n\n // The property is not set at all.\n if (typeof descriptor === 'undefined') {\n return false\n }\n\n // The property is set to a getter that returns undefined.\n if (\n typeof descriptor.get === 'function' &&\n typeof descriptor.get() === 'undefined'\n ) {\n return false\n }\n\n // The property is set to a value equal to undefined.\n if (typeof descriptor.get === 'undefined' && descriptor.value == null) {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"]}
@@ -4,6 +4,12 @@ function hasConfigurableGlobal(propertyName) {
4
4
  if (typeof descriptor === "undefined") {
5
5
  return false;
6
6
  }
7
+ if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") {
8
+ return false;
9
+ }
10
+ if (typeof descriptor.get === "undefined" && descriptor.value == null) {
11
+ return false;
12
+ }
7
13
  if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
8
14
  console.error(
9
15
  `[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`
@@ -16,4 +22,4 @@ function hasConfigurableGlobal(propertyName) {
16
22
  export {
17
23
  hasConfigurableGlobal
18
24
  };
19
- //# sourceMappingURL=chunk-7W52P3VX.mjs.map
25
+ //# sourceMappingURL=chunk-TX5GBTFY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/hasConfigurableGlobal.ts"],"sourcesContent":["/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(propertyName: string): boolean {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName)\n\n // The property is not set at all.\n if (typeof descriptor === 'undefined') {\n return false\n }\n\n // The property is set to a getter that returns undefined.\n if (\n typeof descriptor.get === 'function' &&\n typeof descriptor.get() === 'undefined'\n ) {\n return false\n }\n\n // The property is set to a value equal to undefined.\n if (typeof descriptor.get === 'undefined' && descriptor.value == null) {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"],"mappings":";AAIO,SAAS,sBAAsB,cAA+B;AACnE,QAAM,aAAa,OAAO,yBAAyB,YAAY,YAAY;AAG3E,MAAI,OAAO,eAAe,aAAa;AACrC,WAAO;AAAA,EACT;AAGA,MACE,OAAO,WAAW,QAAQ,cAC1B,OAAO,WAAW,IAAI,MAAM,aAC5B;AACA,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,WAAW,QAAQ,eAAe,WAAW,SAAS,MAAM;AACrE,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,YAAQ;AAAA,MACN,mDAAmD;AAAA,IACrD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkXR7ZDC5Njs = require('../../chunk-XR7ZDC5N.js');
3
+ var _chunkFLQK3CSLjs = require('../../chunk-FLQK3CSL.js');
4
4
  require('../../chunk-LK6DILFK.js');
5
- require('../../chunk-7Z3OOH2U.js');
5
+ require('../../chunk-PFGO5BSM.js');
6
6
  require('../../chunk-IDEEMJ3F.js');
7
7
  require('../../chunk-VCUEA4PL.js');
8
8
  require('../../chunk-AABH3XLQ.js');
9
9
 
10
10
 
11
- exports.XMLHttpRequestInterceptor = _chunkXR7ZDC5Njs.XMLHttpRequestInterceptor;
11
+ exports.XMLHttpRequestInterceptor = _chunkFLQK3CSLjs.XMLHttpRequestInterceptor;
12
12
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  XMLHttpRequestInterceptor
3
- } from "../../chunk-RNZHVDD2.mjs";
3
+ } from "../../chunk-EV33OS3A.mjs";
4
4
  import "../../chunk-6HYIRFX2.mjs";
5
- import "../../chunk-7W52P3VX.mjs";
5
+ import "../../chunk-TX5GBTFY.mjs";
6
6
  import "../../chunk-BZ3Y7YV5.mjs";
7
7
  import "../../chunk-M4WQE4TR.mjs";
8
8
  import "../../chunk-FQQAJBI2.mjs";
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkKVQI7UNNjs = require('../../chunk-KVQI7UNN.js');
4
- require('../../chunk-7Z3OOH2U.js');
3
+ var _chunkCR4RBHMGjs = require('../../chunk-CR4RBHMG.js');
4
+ require('../../chunk-PFGO5BSM.js');
5
5
  require('../../chunk-IDEEMJ3F.js');
6
6
  require('../../chunk-VCUEA4PL.js');
7
7
  require('../../chunk-AABH3XLQ.js');
8
8
 
9
9
 
10
- exports.FetchInterceptor = _chunkKVQI7UNNjs.FetchInterceptor;
10
+ exports.FetchInterceptor = _chunkCR4RBHMGjs.FetchInterceptor;
11
11
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FetchInterceptor
3
- } from "../../chunk-GXB3PZMC.mjs";
4
- import "../../chunk-7W52P3VX.mjs";
3
+ } from "../../chunk-GD7YWPFZ.mjs";
4
+ import "../../chunk-TX5GBTFY.mjs";
5
5
  import "../../chunk-BZ3Y7YV5.mjs";
6
6
  import "../../chunk-M4WQE4TR.mjs";
7
7
  import "../../chunk-FQQAJBI2.mjs";
@@ -3,12 +3,12 @@
3
3
  var _chunkFPLETXGAjs = require('../chunk-FPLETXGA.js');
4
4
 
5
5
 
6
- var _chunkXR7ZDC5Njs = require('../chunk-XR7ZDC5N.js');
6
+ var _chunkFLQK3CSLjs = require('../chunk-FLQK3CSL.js');
7
7
  require('../chunk-LK6DILFK.js');
8
8
 
9
9
 
10
- var _chunkKVQI7UNNjs = require('../chunk-KVQI7UNN.js');
11
- require('../chunk-7Z3OOH2U.js');
10
+ var _chunkCR4RBHMGjs = require('../chunk-CR4RBHMG.js');
11
+ require('../chunk-PFGO5BSM.js');
12
12
  require('../chunk-IDEEMJ3F.js');
13
13
  require('../chunk-VCUEA4PL.js');
14
14
  require('../chunk-AABH3XLQ.js');
@@ -16,8 +16,8 @@ require('../chunk-AABH3XLQ.js');
16
16
  // src/presets/node.ts
17
17
  var node_default = [
18
18
  new (0, _chunkFPLETXGAjs.ClientRequestInterceptor)(),
19
- new (0, _chunkXR7ZDC5Njs.XMLHttpRequestInterceptor)(),
20
- new (0, _chunkKVQI7UNNjs.FetchInterceptor)()
19
+ new (0, _chunkFLQK3CSLjs.XMLHttpRequestInterceptor)(),
20
+ new (0, _chunkCR4RBHMGjs.FetchInterceptor)()
21
21
  ];
22
22
 
23
23
 
@@ -3,12 +3,12 @@ import {
3
3
  } from "../chunk-MG3S53QP.mjs";
4
4
  import {
5
5
  XMLHttpRequestInterceptor
6
- } from "../chunk-RNZHVDD2.mjs";
6
+ } from "../chunk-EV33OS3A.mjs";
7
7
  import "../chunk-6HYIRFX2.mjs";
8
8
  import {
9
9
  FetchInterceptor
10
- } from "../chunk-GXB3PZMC.mjs";
11
- import "../chunk-7W52P3VX.mjs";
10
+ } from "../chunk-GD7YWPFZ.mjs";
11
+ import "../chunk-TX5GBTFY.mjs";
12
12
  import "../chunk-BZ3Y7YV5.mjs";
13
13
  import "../chunk-M4WQE4TR.mjs";
14
14
  import "../chunk-FQQAJBI2.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mswjs/interceptors",
3
3
  "description": "Low-level HTTP/HTTPS/XHR/fetch request interception library.",
4
- "version": "0.36.7",
4
+ "version": "0.36.8",
5
5
  "main": "./lib/node/index.js",
6
6
  "module": "./lib/node/index.mjs",
7
7
  "types": "./lib/node/index.d.ts",
@@ -26,6 +26,30 @@ it('returns false if the global property does not exist', () => {
26
26
  expect(hasConfigurableGlobal('_non-existing')).toBe(false)
27
27
  })
28
28
 
29
+ it('returns false for existing global with undefined as a value', () => {
30
+ Object.defineProperty(global, '_existsAndUndefined', {
31
+ value: undefined,
32
+ configurable: true,
33
+ })
34
+ expect(hasConfigurableGlobal('_existsAndUndefined')).toBe(false)
35
+ })
36
+
37
+ it('returns false for existing global with null as a value', () => {
38
+ Object.defineProperty(global, '_existsAndNull', {
39
+ value: null,
40
+ configurable: true,
41
+ })
42
+ expect(hasConfigurableGlobal('_existsAndNull')).toBe(false)
43
+ })
44
+
45
+ it('returns false for existing global with a getter that returns undefined', () => {
46
+ Object.defineProperty(global, '_existsGetterUndefined', {
47
+ get: () => undefined,
48
+ configurable: true,
49
+ })
50
+ expect(hasConfigurableGlobal('_existsGetterUndefined')).toBe(false)
51
+ })
52
+
29
53
  it('returns false and prints an error for implicitly non-configurable global property', () => {
30
54
  Object.defineProperty(global, '_implicitlyNonConfigurable', {
31
55
  value: 'something',
@@ -5,10 +5,24 @@
5
5
  export function hasConfigurableGlobal(propertyName: string): boolean {
6
6
  const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName)
7
7
 
8
+ // The property is not set at all.
8
9
  if (typeof descriptor === 'undefined') {
9
10
  return false
10
11
  }
11
12
 
13
+ // The property is set to a getter that returns undefined.
14
+ if (
15
+ typeof descriptor.get === 'function' &&
16
+ typeof descriptor.get() === 'undefined'
17
+ ) {
18
+ return false
19
+ }
20
+
21
+ // The property is set to a value equal to undefined.
22
+ if (typeof descriptor.get === 'undefined' && descriptor.value == null) {
23
+ return false
24
+ }
25
+
12
26
  if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {
13
27
  console.error(
14
28
  `[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/hasConfigurableGlobal.ts"],"sourcesContent":["/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(propertyName: string): boolean {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName)\n\n if (typeof descriptor === 'undefined') {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"],"mappings":";AAIO,SAAS,sBAAsB,cAA+B;AACnE,QAAM,aAAa,OAAO,yBAAyB,YAAY,YAAY;AAE3E,MAAI,OAAO,eAAe,aAAa;AACrC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,YAAQ;AAAA,MACN,mDAAmD;AAAA,IACrD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/hasConfigurableGlobal.ts"],"names":[],"mappings":";AAIO,SAAS,sBAAsB,cAA+B;AACnE,QAAM,aAAa,OAAO,yBAAyB,YAAY,YAAY;AAE3E,MAAI,OAAO,eAAe,aAAa;AACrC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,YAAQ;AAAA,MACN,mDAAmD;AAAA,IACrD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT","sourcesContent":["/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(propertyName: string): boolean {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName)\n\n if (typeof descriptor === 'undefined') {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/hasConfigurableGlobal.ts"],"sourcesContent":["/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(propertyName: string): boolean {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName)\n\n if (typeof descriptor === 'undefined') {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"],"mappings":";AAIO,SAAS,sBAAsB,cAA+B;AACnE,QAAM,aAAa,OAAO,yBAAyB,YAAY,YAAY;AAE3E,MAAI,OAAO,eAAe,aAAa;AACrC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,YAAQ;AAAA,MACN,mDAAmD;AAAA,IACrD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/hasConfigurableGlobal.ts"],"names":[],"mappings":";AAIO,SAAS,sBAAsB,cAA+B;AACnE,QAAM,aAAa,OAAO,yBAAyB,YAAY,YAAY;AAE3E,MAAI,OAAO,eAAe,aAAa;AACrC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,WAAW,QAAQ,eAAe,CAAC,WAAW,cAAc;AACrE,YAAQ;AAAA,MACN,mDAAmD;AAAA,IACrD;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT","sourcesContent":["/**\n * Returns a boolean indicating whether the given global property\n * is defined and is configurable.\n */\nexport function hasConfigurableGlobal(propertyName: string): boolean {\n const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName)\n\n if (typeof descriptor === 'undefined') {\n return false\n }\n\n if (typeof descriptor.set === 'undefined' && !descriptor.configurable) {\n console.error(\n `[MSW] Failed to apply interceptor: the global \\`${propertyName}\\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`\n )\n return false\n }\n\n return true\n}\n"]}