1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | 1 1 1 1 1 34 1 217 217 216 216 216 216 1 230 225 230 230 1 201 201 201 201 201 1 230 230 230 1 3 3 3 3 3 1 227 3 3 227 227 227 227 40 40 227 2 2 227 1 1 227 35 35 35 175 175 175 175 35 227 221 27 27 27 23 27 25 27 1 227 227 227 1 7 7 7 7 7 1 283 283 19 264 264 3 264 264 6 264 15 2 13 264 1 1 1 34 3 31 31 31 1 31 31 17 2 15 13 16 16 263 263 17 1 3 246 246 1 245 2 243 243 245 245 245 245 18 18 28 18 17 17 17 3 14 18 18 2 2 16 16 17 18 245 1 244 245 18 227 245 224 224 1 245 1 268 268 3 268 14 268 12 256 256 1 1 212 2 2 212 201 1 7 7 1 2 2 2 2 2 2 1 16 16 2 16 21 21 21 4 4 2 2 14 14 21 21 16 1 5 5 5 1 1 1 1 1 1 1 5 5 1 8 8 1 2 2 230 230 230 1 162 1 42 1 4 1 1 1 1 1 1 1 102 1 121 120 120 105 15 15 15 15 16 16 2 14 2 15 3 15 1 97 1 9 9 6 8 8 8 3 3 1 3 3 3 1 6 6 6 1 3 3 1 2 2 1 1 2 2 1 212 1 2 2 1 1 1 217 217 217 1 28 28 1 6 6 6 1 1 1 20 1 1 1 19 19 1 20 1 1 1 19 1 13 13 12 1 15 15 20 20 20 20 20 3 17 20 20 20 20 20 2 20 1 20 20 15 1 | /* jshint strict:false */ /** * @module nock/scope */ var globalIntercept = require('./intercept') , mixin = require('./mixin') , matchBody = require('./match_body') , common = require('./common') , assert = require('assert') , url = require('url') , _ = require('lodash') , debug = require('debug')('nock.scope') , stringify = require('json-stringify-safe') , EventEmitter = require('events').EventEmitter , extend = require('util')._extend , globalEmitter = require('./global_emitter'); var fs; try { fs = require('fs'); } catch(err) { // do nothing, we're in the browser } function isStream(obj) { return (typeof obj !== 'undefined') && (typeof a !== 'string') && (! Buffer.isBuffer(obj)) && _.isFunction(obj.setEncoding); } function startScope(basePath, options) { var interceptors = {}, scope, transformPathFunction, transformRequestBodyFunction, matchHeaders = [], logger = debug, scopeOptions = options || {}, urlParts = {}, persist = false, contentLen = false, date = null, basePathname = '', port; if (!(basePath instanceof RegExp)) { urlParts = url.parse(basePath); port = urlParts.port || ((urlParts.protocol === 'http:') ? 80 : 443); basePathname = urlParts.pathname.replace(/\/$/, ''); basePath = urlParts.protocol + '//' + urlParts.hostname + ':' + port; } function add(key, interceptor, scope) { if (! interceptors.hasOwnProperty(key)) { interceptors[key] = []; } interceptors[key].push(interceptor); globalIntercept(basePath, interceptor, scope, scopeOptions, urlParts.hostname); } function remove(key, interceptor) { Iif (persist) { return; } var arr = interceptors[key]; Eif (arr) { arr.splice(arr.indexOf(interceptor), 1); if (arr.length === 0) { delete interceptors[key]; } } } function intercept(uri, method, requestBody, interceptorOptions) { var interceptorMatchHeaders = []; var key = method.toUpperCase() + ' ' + basePath + basePathname + uri; var baseUri = method.toUpperCase() + ' ' + basePath + basePathname; function replyWithError(errorMessage) { this.errorMessage = errorMessage; this.options = interceptorOptions || {}; for (var opt in scopeOptions) { if (_.isUndefined(this.options[opt])) { this.options[opt] = scopeOptions[opt]; } } add(key, this, scope, scopeOptions); return scope; } function reply(statusCode, body, headers) { if (arguments.length <= 2 && _.isFunction(statusCode)) { body = statusCode; statusCode = 200; } this.statusCode = statusCode; // We use lower-case headers throughout Nock. headers = common.headersFieldNamesToLowerCase(headers); this.options = interceptorOptions || {}; for (var opt in scopeOptions) { Eif (_.isUndefined(this.options[opt])) { this.options[opt] = scopeOptions[opt]; } } if (scope._defaultReplyHeaders) { headers = headers || {}; headers = mixin(scope._defaultReplyHeaders, headers); } if (date) { headers = headers || {}; headers['date'] = date.toUTCString(); } if (headers !== undefined) { this.headers = {}; this.rawHeaders = []; // makes sure all keys in headers are in lower case for (var key2 in headers) { Eif (headers.hasOwnProperty(key2)) { this.headers[key2.toLowerCase()] = headers[key2]; this.rawHeaders.push(key2); this.rawHeaders.push(headers[key2]); } } debug('reply.rawHeaders:', this.rawHeaders); } // If the content is not encoded we may need to transform the response body. // Otherwise we leave it as it is. if (!common.isContentEncoded(headers)) { if (body && typeof(body) !== 'string' && typeof(body) !== 'function' && !Buffer.isBuffer(body) && !isStream(body)) { try { body = stringify(body); if (!this.headers) { this.headers = {}; } if (!this.headers['content-type']) { this.headers['content-type'] = 'application/json'; } if (contentLen) { this.headers['content-length'] = body.length; } } catch(err) { throw new Error('Error encoding response body into JSON'); } } } this.body = body; add(key, this, scope, scopeOptions); return scope; } function replyWithFile(statusCode, filePath, headers) { Iif (! fs) { throw new Error('No fs'); } var readStream = fs.createReadStream(filePath); readStream.pause(); this.filePath = filePath; return reply.call(this, statusCode, readStream, headers); } function match(options, body, hostNameOnly) { debug('match %s, body = %s', stringify(options), stringify(body)); if (hostNameOnly) { return options.hostname === urlParts.hostname; } var method = (options.method || 'GET').toUpperCase() , path = options.path , matches , matchKey , proto = options.proto; if (transformPathFunction) { path = transformPathFunction(path); } Iif (typeof(body) !== 'string') { body = body.toString(); } if (transformRequestBodyFunction) { body = transformRequestBodyFunction(body, this._requestBody); } var checkHeaders = function(header) { if (_.isFunction(header.value)) { return header.value(options.getHeader(header.name)); } return common.matchStringOrRegexp(options.getHeader(header.name), header.value); }; if (!matchHeaders.every(checkHeaders) || !interceptorMatchHeaders.every(checkHeaders)) { logger('headers don\'t match'); return false; } // Also match request headers // https://github.com/pgte/nock/issues/163 function reqheaderMatches(key) { // We don't try to match request headers if these weren't even specified in the request. if (! options.headers) { return true; } var reqHeader = this.reqheaders[key]; var header = options.headers[key]; if (header && (typeof header !== 'string') && header.toString) { header = header.toString(); } // We skip 'host' header comparison unless it's available in both mock and actual request. // This because 'host' may get inserted by Nock itself and then get recorder. // NOTE: We use lower-case header field names throughout Nock. Iif (key === 'host' && (_.isUndefined(header) || _.isUndefined(reqHeader))) { return true; } if (reqHeader && header) { if (_.isFunction(reqHeader)) { return reqHeader(header); } else if (common.matchStringOrRegexp(header, reqHeader)) { return true; } } debug('request header field doesn\'t match:', key, header, reqHeader); return false; } var reqHeadersMatch = ! this.reqheaders || Object.keys(this.reqheaders).every(reqheaderMatches.bind(this)); if (!reqHeadersMatch) { return false; } function reqheaderContains(header) { return _.has(options.headers, header); } var reqContainsBadHeaders = this.badheaders && _.some(this.badheaders, reqheaderContains); if (reqContainsBadHeaders) { return false; } // If we have a filtered scope then we use it instead reconstructing // the scope from the request options (proto, host and port) as these // two won't necessarily match and we have to remove the scope that was // matched (vs. that was defined). if (this.__nock_filteredScope) { matchKey = this.__nock_filteredScope; } else { matchKey = proto + '://' + options.host; Iif ( options.port && options.host.indexOf(':') < 0 && (options.port !== 80 || options.proto !== 'http') && (options.port !== 443 || options.proto !== 'https') ) { matchKey += ":" + options.port; } } // Match query strings when using query() var matchQueries = true; var queryIndex = -1; var queries; if (this.queries && (queryIndex = path.indexOf('?')) !== -1) { queries = path.slice(queryIndex + 1).split('&'); queries = queries.filter(function(str) { return str.length > 0; }); // Only check for query string matches if this.queries is an object if (_.isObject(this.queries)) { // Make sure that you have an equal number of keys. We are // looping through the passed query params and not the expected values // if the user passes fewer query params than expected but all values // match this will throw a false positive. Testing that the length of the // passed query params is equal to the length of expected keys will prevent // us from doing any value checking BEFORE we know if they have all the proper // params debug('this.queries: %j', this.queries); debug('queries: %j', queries); if (Object.keys(this.queries).length !== queries.length) { matchQueries = false; } else { for (var i = 0; i < queries.length; i++) { var query = queries[i].split('='); if (query[1] === undefined || this.queries[ query[0] ] === undefined) { matchQueries = false; break; } var isMatch = common.matchStringOrRegexp(query[1], this.queries[ query[0] ]); matchQueries = matchQueries && !!isMatch; } } debug('matchQueries: %j', matchQueries); } // Remove the query string from the path path = path.substr(0, queryIndex); } if (typeof uri === 'function') { matches = matchQueries && method.toUpperCase() + ' ' + proto + '://' + options.host === baseUri && uri.call(this, path); } else { matches = method === this.method && common.matchStringOrRegexp(matchKey, this.basePath) && common.matchStringOrRegexp(path, this.path) && matchQueries; } // special logger for query() if (queryIndex !== -1) { logger('matching ' + matchKey + '?' + queries.join('&') + ' to ' + this._key + ' with query(' + stringify(this.queries) + '): ' + matches); } else { logger('matching ' + matchKey + ' to ' + this._key + ': ' + matches); } if (matches) { matches = (matchBody.call(options, this._requestBody, body)); if (!matches) { logger('bodies don\'t match: \n', this._requestBody, '\n', body); } } return matches; } function matchIndependentOfBody(options) { var method = (options.method || 'GET').toUpperCase() , path = options.path , proto = options.proto; if (transformPathFunction) { path = transformPathFunction(path); } var checkHeaders = function(header) { return options.getHeader && common.matchStringOrRegexp(options.getHeader(header.name), header.value); }; if (!matchHeaders.every(checkHeaders) || !interceptorMatchHeaders.every(checkHeaders)) { return false; } var matchKey = method + ' ' + proto + '://' + options.host + path; return this._key === matchKey; } function filteringPath() { if (_.isFunction(arguments[0])) { this.transformFunction = arguments[0]; } return this; } function discard() { if ((persist || this.counter > 0) && this.filePath) { this.body = fs.createReadStream(this.filePath); this.body.pause(); } if (!persist && this.counter < 1) { remove(this._key, this); } } function matchHeader(name, value) { interceptorMatchHeaders.push({ name: name, value: value }); return this; } function basicAuth(options) { var username = options['user']; var password = options['pass'] || ''; var name = 'authorization'; var value = 'Basic ' + new Buffer(username + ':' + password).toString('base64'); interceptorMatchHeaders.push({ name: name, value: value }); return this; } /** * Set query strings for the interceptor * @name query * @param Object Object of query string name,values (accepts regexp values) * @public * @example * // Will match 'http://zombo.com/?q=t' * nock('http://zombo.com').get('/').query({q: 't'}); */ function query(queries) { this.queries = this.queries || {}; // Allow all query strings to match this route if (queries === true) { this.queries = queries; } for (var q in queries) { Eif (_.isUndefined(this.queries[q])) { var value = queries[q]; switch (true) { case _.isNumber(value): // fall-though case _.isBoolean(value): value = value.toString(); break; case _.isUndefined(value): // fall-though case _.isNull(value): value = ''; break; case _.isString(value): if (!scopeOptions.encodedQueryParams) value = common.percentEncode(value); break; } if (!scopeOptions.encodedQueryParams) q = common.percentEncode(q); // everything else, incl. Strings and RegExp values are used 'as-is' this.queries[q] = value; } } return this; } /** * Set number of times will repeat the interceptor * @name times * @param Integer Number of times to repeat (should be > 0) * @public * @example * // Will repeat mock 5 times for same king of request * nock('http://zombo.com).get('/').times(5).reply(200, 'Ok'); */ function times(newCounter) { Iif (newCounter < 1) { return this; } this.counter = newCounter; return this; } /** * An sugar syntax for times(1) * @name once * @see {@link times} * @public * @example * nock('http://zombo.com).get('/').once.reply(200, 'Ok'); */ function once() { return this.times(1); } /** * An sugar syntax for times(2) * @name twice * @see {@link times} * @public * @example * nock('http://zombo.com).get('/').twice.reply(200, 'Ok'); */ function twice() { return this.times(2); } /** * An sugar syntax for times(3). * @name thrice * @see {@link times} * @public * @example * nock('http://zombo.com).get('/').thrice.reply(200, 'Ok'); */ function thrice() { return this.times(3); } /** * Delay the response by a certain number of ms. * * @param {integer} ms - Number of milliseconds to wait * @return {scope} - the current scope for chaining */ function delay(ms) { this.delayInMs = ms; return this; } /** * Delay the connection by a certain number of ms. * * @param {integer} ms - Number of milliseconds to wait * @return {scope} - the current scope for chaining */ function delayConnection(ms) { this.delayConnectionInMs = ms; return this; } /** * Make the socket idle for a certain number of ms (simulated). * * @param {integer} ms - Number of milliseconds to wait * @return {scope} - the current scope for chaining */ function socketDelay(ms) { this.socketDelayInMs = ms; return this; } var interceptor = { _key: key , method: method.toUpperCase() , basePath: basePath , path: (typeof uri === 'string') ? basePathname + uri : uri , counter: 1 , _requestBody: requestBody // We use lower-case header field names throughout Nock. , reqheaders: common.headersFieldNamesToLowerCase((options && options.reqheaders) || {}) , badheaders: common.headersFieldsArrayToLowerCase((options && options.badheaders) || []) , reply: reply , replyWithError: replyWithError , replyWithFile: replyWithFile , discard: discard , match: match , matchIndependentOfBody: matchIndependentOfBody , filteringPath: filteringPath , matchHeader: matchHeader , basicAuth: basicAuth , query: query , times: times , once: once , twice: twice , thrice: thrice , delay: delay , delayConnection: delayConnection , socketDelay: socketDelay , scope: scope }; scope.interceptors.push(interceptor); return interceptor; } function get(uri, requestBody, options) { return intercept(uri, 'GET', requestBody, options); } function post(uri, requestBody, options) { return intercept(uri, 'POST', requestBody, options); } function put(uri, requestBody, options) { return intercept(uri, 'PUT', requestBody, options); } function head(uri, requestBody, options) { return intercept(uri, 'HEAD', requestBody, options); } function patch(uri, requestBody, options) { return intercept(uri, 'PATCH', requestBody, options); } function merge(uri, requestBody, options) { return intercept(uri, 'MERGE', requestBody, options); } function _delete(uri, requestBody, options) { return intercept(uri, 'DELETE', requestBody, options); } function pendingMocks() { return Object.keys(interceptors); } function isDone() { // if nock is turned off, it always says it's done if (! globalIntercept.isOn()) { return true; } var keys = Object.keys(interceptors); if (keys.length === 0) { return true; } else { var doneHostCount = 0; keys.forEach(function(key) { var doneInterceptorCount = 0; interceptors[key].forEach(function(interceptor) { var isRequireDoneDefined = !_.isUndefined(interceptor.options.requireDone); if (isRequireDoneDefined && interceptor.options.requireDone === false) { doneInterceptorCount += 1; } else if (persist && interceptor.interceptionCounter > 0) { doneInterceptorCount += 1; } }); if (doneInterceptorCount === interceptors[key].length ) { doneHostCount += 1; } }); return (doneHostCount === keys.length); } } function done() { assert.ok(isDone(), "Mocks not yet satisfied:\n" + pendingMocks().join("\n")); } function buildFilter() { var filteringArguments = arguments; if (arguments[0] instanceof RegExp) { return function(candidate) { Eif (candidate) { candidate = candidate.replace(filteringArguments[0], filteringArguments[1]); } return candidate; }; } else Eif (_.isFunction(arguments[0])) { return arguments[0]; } } function filteringPath() { transformPathFunction = buildFilter.apply(undefined, arguments); Iif (!transformPathFunction) { throw new Error('Invalid arguments: filtering path should be a function or a regular expression'); } return this; } function filteringRequestBody() { transformRequestBodyFunction = buildFilter.apply(undefined, arguments); Iif (!transformRequestBodyFunction) { throw new Error('Invalid arguments: filtering request body should be a function or a regular expression'); } return this; } function matchHeader(name, value) { // We use lower-case header field names throughout Nock. matchHeaders.push({ name: name.toLowerCase(), value: value }); return this; } function defaultReplyHeaders(headers) { this._defaultReplyHeaders = common.headersFieldNamesToLowerCase(headers); return this; } function log(newLogger) { logger = newLogger; return this; } function _persist() { persist = true; return this; } function shouldPersist() { return persist; } function replyContentLength() { contentLen = true; return this; } function replyDate(d) { date = d || new Date(); return this; } scope = new EventEmitter(); extend(scope, { get: get , post: post , delete: _delete , put: put , merge: merge , patch: patch , head: head , intercept: intercept , done: done , isDone: isDone , filteringPath: filteringPath , filteringRequestBody: filteringRequestBody , matchHeader: matchHeader , defaultReplyHeaders: defaultReplyHeaders , log: log , persist: _persist , shouldPersist: shouldPersist , pendingMocks: pendingMocks , replyContentLength: replyContentLength , replyDate: replyDate , interceptors: [], }); return scope; } function cleanAll() { globalIntercept.removeAll(); return module.exports; } function loadDefs(path) { Iif (! fs) { throw new Error('No fs'); } var contents = fs.readFileSync(path); return JSON.parse(contents); } function load(path) { return define(loadDefs(path)); } function getStatusFromDefinition(nockDef) { // Backward compatibility for when `status` was encoded as string in `reply`. if (!_.isUndefined(nockDef.reply)) { // Try parsing `reply` property. var parsedReply = parseInt(nockDef.reply, 10); Eif (_.isNumber(parsedReply)) { return parsedReply; } } var DEFAULT_STATUS_OK = 200; return nockDef.status || DEFAULT_STATUS_OK; } function getScopeFromDefinition(nockDef) { // Backward compatibility for when `port` was part of definition. if (!_.isUndefined(nockDef.port)) { // Include `port` into scope if it doesn't exist. var options = url.parse(nockDef.scope); Eif (_.isNull(options.port)) { return nockDef.scope + ':' + nockDef.port; } else { if (parseInt(options.port) !== parseInt(nockDef.port)) { throw new Error('Mismatched port numbers in scope and port properties of nock definition.'); } } } return nockDef.scope; } function tryJsonParse(string) { try { return JSON.parse(string); } catch(err) { return string; } } function define(nockDefs) { var nocks = []; nockDefs.forEach(function(nockDef) { var nscope = getScopeFromDefinition(nockDef) , npath = nockDef.path , method = nockDef.method.toLowerCase() || "get" , status = getStatusFromDefinition(nockDef) , headers = nockDef.headers || {} , reqheaders = nockDef.reqheaders || {} , body = nockDef.body || '' , options = nockDef.options || {}; // We use request headers for both filtering (see below) and mocking. // Here we are setting up mocked request headers but we don't want to // be changing the user's options object so we clone it first. options = _.clone(options) || {}; options.reqheaders = reqheaders; // Response is not always JSON as it could be a string or binary data or // even an array of binary buffers (e.g. when content is enconded) var response; if (!nockDef.response) { response = ''; } else { response = _.isString(nockDef.response) ? tryJsonParse(nockDef.response) : nockDef.response; } var nock; Iif (body==="*") { nock = startScope(nscope, options).filteringRequestBody(function() { return "*"; })[method](npath, "*").reply(status, response, headers); } else { nock = startScope(nscope, options); // If request headers were specified filter by them. Eif (reqheaders !== {}) { for (var k in reqheaders) { nock.matchHeader(k, reqheaders[k]); } } if (nockDef.filteringRequestBody) { nock.filteringRequestBody(nockDef.filteringRequestBody); } nock.intercept(npath, method, body).reply(status, response, headers); } nocks.push(nock); }); return nocks; } module.exports = extend(startScope, { cleanAll: cleanAll, activate: globalIntercept.activate, isActive: globalIntercept.isActive, isDone: globalIntercept.isDone, pendingMocks: globalIntercept.pendingMocks, removeInterceptor: globalIntercept.removeInterceptor, disableNetConnect: globalIntercept.disableNetConnect, enableNetConnect: globalIntercept.enableNetConnect, load: load, loadDefs: loadDefs, define: define, emitter: globalEmitter, }); |