@hyper-fetch/core 5.1.2 → 5.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper-fetch/core",
3
- "version": "5.1.2",
3
+ "version": "5.2.0",
4
4
  "private": false,
5
5
  "description": "Cache, Queue and Persist your requests no matter if you are online or offline!",
6
6
  "author": "Maciej Pyrc <m.pyrc@interia.pl>",
@@ -338,7 +338,8 @@ export const getAdapterBindings = async <T extends AdapterInstance = AdapterType
338
338
  if (processingError) {
339
339
  return onError(processingError, systemErrorStatus, systemErrorExtra, () => null);
340
340
  }
341
- if (req.mock && req.isMockEnabled) {
341
+
342
+ if (req.mock && req.isMockEnabled && req.client.isMockEnabled) {
342
343
  return mocker(request, {
343
344
  onError,
344
345
  onResponseEnd,
@@ -69,6 +69,8 @@ export class Client<
69
69
  defaultMethod: ExtractAdapterMethodType<Adapter> = HttpMethodsEnum.get as ExtractAdapterMethodType<Adapter>;
70
70
  defaultExtra: ExtractAdapterExtraType<Adapter> = xhrExtra as ExtractAdapterExtraType<Adapter>;
71
71
 
72
+ isMockEnabled = true;
73
+
72
74
  // Registered requests effect
73
75
  effects: RequestEffectInstance[] = [];
74
76
 
@@ -199,6 +201,15 @@ export class Client<
199
201
  return this;
200
202
  };
201
203
 
204
+ /**
205
+ * Set globally if mocking should be enabled or disabled for all client requests.
206
+ * @param isMockEnabled
207
+ */
208
+ setEnableGlobalMocking = (isMockEnabled: boolean) => {
209
+ this.isMockEnabled = isMockEnabled;
210
+ return this;
211
+ };
212
+
202
213
  /**
203
214
  * Set the request payload mapping function which get triggered before request get send
204
215
  */