msw 0.39.2 → 0.40.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/lib/umd/index.js CHANGED
@@ -2004,6 +2004,12 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
2004
2004
  console.groupCollapsed(`%c${devUtils.formatMessage(message)}`, 'color:orangered;font-weight:bold;');
2005
2005
  console.log('%cDocumentation: %chttps://mswjs.io/docs', 'font-weight:bold', 'font-weight:normal');
2006
2006
  console.log('Found an issue? https://github.com/mswjs/msw/issues');
2007
+ if (args.workerUrl) {
2008
+ console.log('Worker script URL:', args.workerUrl);
2009
+ }
2010
+ if (args.workerScope) {
2011
+ console.log('Worker scope:', args.workerScope);
2012
+ }
2007
2013
  console.groupEnd();
2008
2014
  }
2009
2015
 
@@ -2011,10 +2017,22 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
2011
2017
  * Signals the worker to enable the interception of requests.
2012
2018
  */
2013
2019
  function enableMocking(context, options) {
2020
+ var _a, _b;
2014
2021
  return __awaiter$3(this, void 0, void 0, function* () {
2015
2022
  context.workerChannel.send('MOCK_ACTIVATE');
2016
- return context.events.once('MOCKING_ENABLED').then(() => {
2017
- printStartMessage({ quiet: options.quiet });
2023
+ yield context.events.once('MOCKING_ENABLED');
2024
+ // Warn the developer on multiple "worker.start()" calls.
2025
+ // While this will not affect the worker in any way,
2026
+ // it likely indicates an issue with the developer's code.
2027
+ if (context.isMockingEnabled) {
2028
+ devUtils.warn(`Found a redundant "worker.start()" call. Note that starting the worker while mocking is already enabled will have no effect. Consider removing this "worker.start()" call.`);
2029
+ return;
2030
+ }
2031
+ context.isMockingEnabled = true;
2032
+ printStartMessage({
2033
+ quiet: options.quiet,
2034
+ workerScope: (_a = context.registration) === null || _a === void 0 ? void 0 : _a.scope,
2035
+ workerUrl: (_b = context.worker) === null || _b === void 0 ? void 0 : _b.scriptURL,
2018
2036
  });
2019
2037
  });
2020
2038
  }
@@ -2044,6 +2062,196 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
2044
2062
  }
2045
2063
  }
2046
2064
 
2065
+ /**
2066
+ * Composes a given list of functions into a new function that
2067
+ * executes from right to left.
2068
+ */
2069
+ function compose(...fns) {
2070
+ return (...args) => {
2071
+ return fns.reduceRight((leftFn, rightFn) => {
2072
+ return leftFn instanceof Promise
2073
+ ? Promise.resolve(leftFn).then(rightFn)
2074
+ : rightFn(leftFn);
2075
+ }, args[0]);
2076
+ };
2077
+ }
2078
+
2079
+ const defaultResponse = {
2080
+ status: 200,
2081
+ statusText: 'OK',
2082
+ body: null,
2083
+ delay: 0,
2084
+ once: false,
2085
+ passthrough: false,
2086
+ };
2087
+ const defaultResponseTransformers = [];
2088
+ function createResponseComposition(responseOverrides, defaultTransformers = defaultResponseTransformers) {
2089
+ return (...transformers) => __awaiter$3(this, void 0, void 0, function* () {
2090
+ const initialResponse = Object.assign({}, defaultResponse, {
2091
+ headers: new lib$7.Headers({
2092
+ 'x-powered-by': 'msw',
2093
+ }),
2094
+ }, responseOverrides);
2095
+ const resolvedTransformers = [
2096
+ ...defaultTransformers,
2097
+ ...transformers,
2098
+ ].filter(Boolean);
2099
+ const resolvedResponse = resolvedTransformers.length > 0
2100
+ ? compose(...resolvedTransformers)(initialResponse)
2101
+ : initialResponse;
2102
+ return resolvedResponse;
2103
+ });
2104
+ }
2105
+ const response = Object.assign(createResponseComposition(), {
2106
+ once: createResponseComposition({ once: true }),
2107
+ networkError(message) {
2108
+ throw new NetworkError(message);
2109
+ },
2110
+ });
2111
+
2112
+ const BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](umd|esm|iief|cjs)[\/\\]|^[^\/\\]*$/;
2113
+ /**
2114
+ * Return the stack trace frame of a function's invocation.
2115
+ */
2116
+ function getCallFrame(error) {
2117
+ // In <IE11, new Error may return an undefined stack
2118
+ const stack = error.stack;
2119
+ if (!stack) {
2120
+ return;
2121
+ }
2122
+ const frames = stack.split('\n').slice(1);
2123
+ // Get the first frame that doesn't reference the library's internal trace.
2124
+ // Assume that frame is the invocation frame.
2125
+ const declarationFrame = frames.find((frame) => {
2126
+ return !BUILD_FRAME.test(frame);
2127
+ });
2128
+ if (!declarationFrame) {
2129
+ return;
2130
+ }
2131
+ // Extract file reference from the stack frame.
2132
+ const declarationPath = declarationFrame
2133
+ .replace(/\s*at [^()]*\(([^)]+)\)/, '$1')
2134
+ .replace(/^@/, '');
2135
+ return declarationPath;
2136
+ }
2137
+
2138
+ /**
2139
+ * Determines if the given function is an iterator.
2140
+ */
2141
+ function isIterable(fn) {
2142
+ if (!fn) {
2143
+ return false;
2144
+ }
2145
+ return typeof fn[Symbol.iterator] == 'function';
2146
+ }
2147
+
2148
+ const defaultContext = {
2149
+ status,
2150
+ set,
2151
+ delay,
2152
+ fetch: fetch$1,
2153
+ };
2154
+ class RequestHandler {
2155
+ constructor(options) {
2156
+ this.shouldSkip = false;
2157
+ this.ctx = options.ctx || defaultContext;
2158
+ this.resolver = options.resolver;
2159
+ const callFrame = getCallFrame(new Error());
2160
+ this.info = Object.assign(Object.assign({}, options.info), { callFrame });
2161
+ }
2162
+ /**
2163
+ * Parse the captured request to extract additional information from it.
2164
+ * Parsed result is then exposed to other methods of this request handler.
2165
+ */
2166
+ parse(_request, _resolutionContext) {
2167
+ return null;
2168
+ }
2169
+ /**
2170
+ * Test if this handler matches the given request.
2171
+ */
2172
+ test(request, resolutionContext) {
2173
+ return this.predicate(request, this.parse(request, resolutionContext), resolutionContext);
2174
+ }
2175
+ /**
2176
+ * Derive the publicly exposed request (`req`) instance of the response resolver
2177
+ * from the captured request and its parsed result.
2178
+ */
2179
+ getPublicRequest(request, _parsedResult) {
2180
+ return request;
2181
+ }
2182
+ markAsSkipped(shouldSkip = true) {
2183
+ this.shouldSkip = shouldSkip;
2184
+ }
2185
+ /**
2186
+ * Execute this request handler and produce a mocked response
2187
+ * using the given resolver function.
2188
+ */
2189
+ run(request, resolutionContext) {
2190
+ return __awaiter$3(this, void 0, void 0, function* () {
2191
+ if (this.shouldSkip) {
2192
+ return null;
2193
+ }
2194
+ const parsedResult = this.parse(request, resolutionContext);
2195
+ const shouldIntercept = this.predicate(request, parsedResult, resolutionContext);
2196
+ if (!shouldIntercept) {
2197
+ return null;
2198
+ }
2199
+ const publicRequest = this.getPublicRequest(request, parsedResult);
2200
+ // Create a response extraction wrapper around the resolver
2201
+ // since it can be both an async function and a generator.
2202
+ const executeResolver = this.wrapResolver(this.resolver);
2203
+ const mockedResponse = yield executeResolver(publicRequest, response, this.ctx);
2204
+ return this.createExecutionResult(parsedResult, publicRequest, mockedResponse);
2205
+ });
2206
+ }
2207
+ wrapResolver(resolver) {
2208
+ return (req, res, ctx) => __awaiter$3(this, void 0, void 0, function* () {
2209
+ const result = this.resolverGenerator || (yield resolver(req, res, ctx));
2210
+ if (isIterable(result)) {
2211
+ const { value, done } = result[Symbol.iterator]().next();
2212
+ const nextResponse = yield value;
2213
+ // If the generator is done and there is no next value,
2214
+ // return the previous generator's value.
2215
+ if (!nextResponse && done) {
2216
+ return this.resolverGeneratorResult;
2217
+ }
2218
+ if (!this.resolverGenerator) {
2219
+ this.resolverGenerator = result;
2220
+ }
2221
+ this.resolverGeneratorResult = nextResponse;
2222
+ return nextResponse;
2223
+ }
2224
+ return result;
2225
+ });
2226
+ }
2227
+ createExecutionResult(parsedResult, request, response) {
2228
+ return {
2229
+ handler: this,
2230
+ parsedResult: parsedResult || null,
2231
+ request,
2232
+ response: response || null,
2233
+ };
2234
+ }
2235
+ }
2236
+ /**
2237
+ * Bypass this intercepted request.
2238
+ * This will make a call to the actual endpoint requested.
2239
+ */
2240
+ function passthrough() {
2241
+ // Constructing a dummy "101 Continue" mocked response
2242
+ // to keep the return type of the resolver consistent.
2243
+ return {
2244
+ status: 101,
2245
+ statusText: 'Continue',
2246
+ headers: new lib$7.Headers(),
2247
+ body: null,
2248
+ // Setting "passthrough" to true will signal the response pipeline
2249
+ // to perform this intercepted request as-is.
2250
+ passthrough: true,
2251
+ once: false,
2252
+ };
2253
+ }
2254
+
2047
2255
  var lib$2 = {};
2048
2256
 
2049
2257
  var CookieStore = {};
@@ -2635,6 +2843,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2635
2843
  body: pruneGetRequestBody(rawRequest),
2636
2844
  bodyUsed: rawRequest.bodyUsed,
2637
2845
  headers: new lib$7.Headers(rawRequest.headers),
2846
+ passthrough,
2638
2847
  };
2639
2848
  // Set document cookies on the request.
2640
2849
  setRequestCookies(request);
@@ -25830,177 +26039,6 @@ spurious results.`);
25830
26039
  };
25831
26040
  }
25832
26041
 
25833
- /**
25834
- * Composes a given list of functions into a new function that
25835
- * executes from right to left.
25836
- */
25837
- function compose(...fns) {
25838
- return (...args) => {
25839
- return fns.reduceRight((leftFn, rightFn) => {
25840
- return leftFn instanceof Promise
25841
- ? Promise.resolve(leftFn).then(rightFn)
25842
- : rightFn(leftFn);
25843
- }, args[0]);
25844
- };
25845
- }
25846
-
25847
- const defaultResponse = {
25848
- status: 200,
25849
- statusText: 'OK',
25850
- body: null,
25851
- delay: 0,
25852
- once: false,
25853
- };
25854
- const defaultResponseTransformers = [];
25855
- function createResponseComposition(responseOverrides, defaultTransformers = defaultResponseTransformers) {
25856
- return (...transformers) => __awaiter$3(this, void 0, void 0, function* () {
25857
- const initialResponse = Object.assign({}, defaultResponse, {
25858
- headers: new lib$7.Headers({
25859
- 'x-powered-by': 'msw',
25860
- }),
25861
- }, responseOverrides);
25862
- const resolvedTransformers = [
25863
- ...defaultTransformers,
25864
- ...transformers,
25865
- ].filter(Boolean);
25866
- const resolvedResponse = resolvedTransformers.length > 0
25867
- ? compose(...resolvedTransformers)(initialResponse)
25868
- : initialResponse;
25869
- return resolvedResponse;
25870
- });
25871
- }
25872
- const response = Object.assign(createResponseComposition(), {
25873
- once: createResponseComposition({ once: true }),
25874
- networkError(message) {
25875
- throw new NetworkError(message);
25876
- },
25877
- });
25878
-
25879
- const BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](umd|esm|iief|cjs)[\/\\]|^[^\/\\]*$/;
25880
- /**
25881
- * Return the stack trace frame of a function's invocation.
25882
- */
25883
- function getCallFrame(error) {
25884
- // In <IE11, new Error may return an undefined stack
25885
- const stack = error.stack;
25886
- if (!stack) {
25887
- return;
25888
- }
25889
- const frames = stack.split('\n').slice(1);
25890
- // Get the first frame that doesn't reference the library's internal trace.
25891
- // Assume that frame is the invocation frame.
25892
- const declarationFrame = frames.find((frame) => {
25893
- return !BUILD_FRAME.test(frame);
25894
- });
25895
- if (!declarationFrame) {
25896
- return;
25897
- }
25898
- // Extract file reference from the stack frame.
25899
- const declarationPath = declarationFrame
25900
- .replace(/\s*at [^()]*\(([^)]+)\)/, '$1')
25901
- .replace(/^@/, '');
25902
- return declarationPath;
25903
- }
25904
-
25905
- /**
25906
- * Determines if the given function is an iterator.
25907
- */
25908
- function isIterable(fn) {
25909
- if (!fn) {
25910
- return false;
25911
- }
25912
- return typeof fn[Symbol.iterator] == 'function';
25913
- }
25914
-
25915
- const defaultContext = {
25916
- status,
25917
- set,
25918
- delay,
25919
- fetch: fetch$1,
25920
- };
25921
- class RequestHandler {
25922
- constructor(options) {
25923
- this.shouldSkip = false;
25924
- this.ctx = options.ctx || defaultContext;
25925
- this.resolver = options.resolver;
25926
- const callFrame = getCallFrame(new Error());
25927
- this.info = Object.assign(Object.assign({}, options.info), { callFrame });
25928
- }
25929
- /**
25930
- * Parse the captured request to extract additional information from it.
25931
- * Parsed result is then exposed to other methods of this request handler.
25932
- */
25933
- parse(_request, _resolutionContext) {
25934
- return null;
25935
- }
25936
- /**
25937
- * Test if this handler matches the given request.
25938
- */
25939
- test(request, resolutionContext) {
25940
- return this.predicate(request, this.parse(request, resolutionContext), resolutionContext);
25941
- }
25942
- /**
25943
- * Derive the publicly exposed request (`req`) instance of the response resolver
25944
- * from the captured request and its parsed result.
25945
- */
25946
- getPublicRequest(request, _parsedResult) {
25947
- return request;
25948
- }
25949
- markAsSkipped(shouldSkip = true) {
25950
- this.shouldSkip = shouldSkip;
25951
- }
25952
- /**
25953
- * Execute this request handler and produce a mocked response
25954
- * using the given resolver function.
25955
- */
25956
- run(request, resolutionContext) {
25957
- return __awaiter$3(this, void 0, void 0, function* () {
25958
- if (this.shouldSkip) {
25959
- return null;
25960
- }
25961
- const parsedResult = this.parse(request, resolutionContext);
25962
- const shouldIntercept = this.predicate(request, parsedResult, resolutionContext);
25963
- if (!shouldIntercept) {
25964
- return null;
25965
- }
25966
- const publicRequest = this.getPublicRequest(request, parsedResult);
25967
- // Create a response extraction wrapper around the resolver
25968
- // since it can be both an async function and a generator.
25969
- const executeResolver = this.wrapResolver(this.resolver);
25970
- const mockedResponse = yield executeResolver(publicRequest, response, this.ctx);
25971
- return this.createExecutionResult(parsedResult, publicRequest, mockedResponse);
25972
- });
25973
- }
25974
- wrapResolver(resolver) {
25975
- return (req, res, ctx) => __awaiter$3(this, void 0, void 0, function* () {
25976
- const result = this.resolverGenerator || (yield resolver(req, res, ctx));
25977
- if (isIterable(result)) {
25978
- const { value, done } = result[Symbol.iterator]().next();
25979
- const nextResponse = yield value;
25980
- // If the generator is done and there is no next value,
25981
- // return the previous generator's value.
25982
- if (!nextResponse && done) {
25983
- return this.resolverGeneratorResult;
25984
- }
25985
- if (!this.resolverGenerator) {
25986
- this.resolverGenerator = result;
25987
- }
25988
- this.resolverGeneratorResult = nextResponse;
25989
- return nextResponse;
25990
- }
25991
- return result;
25992
- });
25993
- }
25994
- createExecutionResult(parsedResult, request, response) {
25995
- return {
25996
- handler: this,
25997
- parsedResult: parsedResult || null,
25998
- request,
25999
- response: response || null,
26000
- };
26001
- }
26002
- }
26003
-
26004
26042
  exports.RESTMethods = void 0;
26005
26043
  (function (RESTMethods) {
26006
26044
  RESTMethods["HEAD"] = "HEAD";
@@ -26011,17 +26049,11 @@ spurious results.`);
26011
26049
  RESTMethods["OPTIONS"] = "OPTIONS";
26012
26050
  RESTMethods["DELETE"] = "DELETE";
26013
26051
  })(exports.RESTMethods || (exports.RESTMethods = {}));
26014
- const restContext = {
26015
- set,
26016
- status,
26017
- cookie,
26052
+ const restContext = Object.assign(Object.assign({}, defaultContext), { cookie,
26018
26053
  body,
26019
26054
  text,
26020
26055
  json,
26021
- xml,
26022
- delay,
26023
- fetch: fetch$1,
26024
- };
26056
+ xml });
26025
26057
  /**
26026
26058
  * Request handler for REST API requests.
26027
26059
  * Provides request matching based on method and URL.
@@ -26092,16 +26124,10 @@ spurious results.`);
26092
26124
  }
26093
26125
  }
26094
26126
 
26095
- const graphqlContext = {
26096
- set,
26097
- status,
26098
- delay,
26099
- fetch: fetch$1,
26100
- data,
26127
+ const graphqlContext = Object.assign(Object.assign({}, defaultContext), { data,
26101
26128
  extensions,
26102
26129
  errors,
26103
- cookie,
26104
- };
26130
+ cookie });
26105
26131
  function isDocumentNode(value) {
26106
26132
  if (value == null) {
26107
26133
  return false;
@@ -26321,17 +26347,24 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
26321
26347
  }
26322
26348
 
26323
26349
  function handleRequest(request, handlers, options, emitter, handleRequestOptions) {
26324
- var _a, _b, _c;
26350
+ var _a, _b, _c, _d;
26325
26351
  return __awaiter$3(this, void 0, void 0, function* () {
26326
26352
  emitter.emit('request:start', request);
26327
26353
  // Perform bypassed requests (i.e. issued via "ctx.fetch") as-is.
26328
26354
  if (request.headers.get('x-msw-bypass') === 'true') {
26329
26355
  emitter.emit('request:end', request);
26330
- (_a = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onBypassResponse) === null || _a === void 0 ? void 0 : _a.call(handleRequestOptions, request);
26356
+ (_a = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onPassthroughResponse) === null || _a === void 0 ? void 0 : _a.call(handleRequestOptions, request);
26331
26357
  return;
26332
26358
  }
26333
26359
  // Resolve a mocked response from the list of request handlers.
26334
- const lookupResult = yield getResponse(request, handlers, handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.resolutionContext);
26360
+ const [lookupError, lookupResult] = yield until(() => {
26361
+ return getResponse(request, handlers, handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.resolutionContext);
26362
+ });
26363
+ if (lookupError) {
26364
+ // Allow developers to react to unhandled exceptions in request handlers.
26365
+ emitter.emit('unhandledException', lookupError, request);
26366
+ throw lookupError;
26367
+ }
26335
26368
  const { handler, response } = lookupResult;
26336
26369
  // When there's no handler for the request, consider it unhandled.
26337
26370
  // Allow the developer to react to such cases.
@@ -26339,7 +26372,7 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
26339
26372
  onUnhandledRequest(request, handlers, options.onUnhandledRequest);
26340
26373
  emitter.emit('request:unhandled', request);
26341
26374
  emitter.emit('request:end', request);
26342
- (_b = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onBypassResponse) === null || _b === void 0 ? void 0 : _b.call(handleRequestOptions, request);
26375
+ (_b = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onPassthroughResponse) === null || _b === void 0 ? void 0 : _b.call(handleRequestOptions, request);
26343
26376
  return;
26344
26377
  }
26345
26378
  // When the handled request returned no mocked response, warn the developer,
@@ -26352,7 +26385,14 @@ Expected response resolver to return a mocked response Object, but got %s. The o
26352
26385
  %s\
26353
26386
  `, response, handler.info.header, handler.info.callFrame);
26354
26387
  emitter.emit('request:end', request);
26355
- (_c = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onBypassResponse) === null || _c === void 0 ? void 0 : _c.call(handleRequestOptions, request);
26388
+ (_c = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onPassthroughResponse) === null || _c === void 0 ? void 0 : _c.call(handleRequestOptions, request);
26389
+ return;
26390
+ }
26391
+ // When the developer explicitly returned "req.passthrough()" do not warn them.
26392
+ // Perform the request as-is.
26393
+ if (response.passthrough) {
26394
+ emitter.emit('request:end', request);
26395
+ (_d = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onPassthroughResponse) === null || _d === void 0 ? void 0 : _d.call(handleRequestOptions, request);
26356
26396
  return;
26357
26397
  }
26358
26398
  // Store all the received response cookies in the virtual cookie store.
@@ -26383,7 +26423,7 @@ Expected response resolver to return a mocked response Object, but got %s. The o
26383
26423
  transformResponse(response) {
26384
26424
  return Object.assign(Object.assign({}, response), { headers: response.headers.all() });
26385
26425
  },
26386
- onBypassResponse() {
26426
+ onPassthroughResponse() {
26387
26427
  return channel.send({
26388
26428
  type: 'MOCK_NOT_FOUND',
26389
26429
  });
@@ -26413,19 +26453,21 @@ Expected response resolver to return a mocked response Object, but got %s. The o
26413
26453
  },
26414
26454
  });
26415
26455
  }
26416
- // Treat all the other exceptions in a request handler
26417
- // as unintended, alerting that there is a problem needs fixing.
26418
- channel.send({
26419
- type: 'INTERNAL_ERROR',
26420
- payload: {
26421
- status: 500,
26422
- body: JSON.stringify({
26423
- errorType: error.constructor.name,
26424
- message: error.message,
26425
- location: error.stack,
26426
- }),
26427
- },
26428
- });
26456
+ if (error instanceof Error) {
26457
+ // Treat all the other exceptions in a request handler
26458
+ // as unintended, alerting that there is a problem needs fixing.
26459
+ channel.send({
26460
+ type: 'INTERNAL_ERROR',
26461
+ payload: {
26462
+ status: 500,
26463
+ body: JSON.stringify({
26464
+ errorType: error.constructor.name,
26465
+ message: error.message,
26466
+ location: error.stack,
26467
+ }),
26468
+ },
26469
+ });
26470
+ }
26429
26471
  }
26430
26472
  });
26431
26473
  };
@@ -26605,12 +26647,19 @@ If this message still persists after updating, please report an issue: https://g
26605
26647
  const createStop = (context) => {
26606
26648
  return function stop() {
26607
26649
  var _a;
26650
+ // Warn developers calling "worker.stop()" more times than necessary.
26651
+ // This likely indicates a mistake in their code.
26652
+ if (!context.isMockingEnabled) {
26653
+ devUtils.warn('Found a redundant "worker.stop()" call. Note that stopping the worker while mocking already stopped has no effect. Consider removing this "worker.stop()" call.');
26654
+ return;
26655
+ }
26608
26656
  /**
26609
26657
  * Signal the Service Worker to disable mocking for this client.
26610
26658
  * Use this an an explicit way to stop the mocking, while preserving
26611
26659
  * the worker-client relation. Does not affect the worker's lifecycle.
26612
26660
  */
26613
26661
  context.workerChannel.send('MOCK_DEACTIVATE');
26662
+ context.isMockingEnabled = false;
26614
26663
  window.clearInterval(context.keepAliveInterval);
26615
26664
  printStopMessage({ quiet: (_a = context.startOptions) === null || _a === void 0 ? void 0 : _a.quiet });
26616
26665
  };
@@ -31268,6 +31317,7 @@ If this message still persists after updating, please report an issue: https://g
31268
31317
  integrity: '',
31269
31318
  destination: 'document',
31270
31319
  bodyUsed: false,
31320
+ passthrough,
31271
31321
  };
31272
31322
  // Attach all the cookies from the virtual cookie store.
31273
31323
  setRequestCookies(mockedRequest);
@@ -31362,6 +31412,9 @@ If this message still persists after updating, please report an issue: https://g
31362
31412
  const publicEmitter = new lib$5.StrictEventEmitter();
31363
31413
  pipeEvents(emitter, publicEmitter);
31364
31414
  const context = {
31415
+ // Mocking is not considered enabled until the worker
31416
+ // signals back the successful activation event.
31417
+ isMockingEnabled: false,
31365
31418
  startOptions: undefined,
31366
31419
  worker: null,
31367
31420
  registration: null,
@@ -2,7 +2,7 @@
2
2
  /* tslint:disable */
3
3
 
4
4
  /**
5
- * Mock Service Worker (0.39.2).
5
+ * Mock Service Worker (0.40.2).
6
6
  * @see https://github.com/mswjs/msw
7
7
  * - Please do NOT modify this file.
8
8
  * - Please do NOT serve this file on production.