{
  "type": "module",
  "source": "doc/api/api-mockagent.md",
  "modules": [
    {
      "textRaw": "MockAgent",
      "name": "mockagent",
      "introduced_in": "v4.0.0",
      "type": "module",
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p>A <code>MockAgent</code> is a <a href=\"Dispatcher.md#class-dispatcher\"><code>&#x3C;Dispatcher></code></a> that intercepts HTTP requests made through\nundici and replies with programmed mock responses instead of contacting the\nnetwork. It is useful for testing code that performs HTTP requests without\nrelying on a live server.</p>\n<p>A <code>MockAgent</code> does not intercept requests on its own. Mock responses are\nregistered on the <a href=\"MockClient.md#class-mockclient\"><code>&#x3C;MockClient></code></a> or <a href=\"MockPool.md#class-mockpool\"><code>&#x3C;MockPool></code></a> instances returned by <a href=\"#mockagentgetorigin\"><code>mockAgent.get(origin)</code></a>, and requests are routed through them once the\n<code>MockAgent</code> is set as the dispatcher (for example through\n<a href=\"Dispatcher.html#setglobaldispatcherdispatcher\"><code>setGlobalDispatcher()</code></a> or a per-request <code>dispatcher</code> option).</p>\n<pre><code class=\"language-mjs\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent()\n</code></pre>",
      "classes": [
        {
          "textRaw": "Class: `MockAgent`",
          "name": "MockAgent",
          "type": "class",
          "meta": {
            "added": [
              "v4.0.0"
            ],
            "changes": []
          },
          "desc": "<ul>\n<li>Extends: <a href=\"Dispatcher.md#class-dispatcher\"><code>&#x3C;Dispatcher></code></a></li>\n</ul>\n<p>Intercepts HTTP requests made through undici and returns mocked responses.</p>",
          "signatures": [
            {
              "textRaw": "`new MockAgent([options])`",
              "name": "MockAgent",
              "type": "ctor",
              "meta": {
                "added": [
                  "v4.0.0"
                ],
                "changes": [
                  {
                    "version": "v7.16.0",
                    "pr-url": "https://github.com/nodejs/undici/pull/4479",
                    "description": "Mock options are always normalized to an object internally."
                  }
                ]
              },
              "params": [
                {
                  "textRaw": "`options` {MockAgentOptions} (optional)",
                  "name": "options",
                  "type": "MockAgentOptions",
                  "desc": "(optional)",
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {MockAgent}",
                "name": "return",
                "type": "MockAgent"
              },
              "desc": "<p>When instantiated, a <code>MockAgent</code> is automatically activated. It does not\nintercept any request until mock interceptors are registered on the dispatchers\nreturned by <a href=\"#mockagentgetorigin\"><code>mockAgent.get(origin)</code></a>.</p>",
              "modules": [
                {
                  "textRaw": "Parameter: `MockAgentOptions`",
                  "name": "parameter:_`mockagentoptions`",
                  "type": "module",
                  "desc": "<ul>\n<li>Extends: <a href=\"Agent.md#new-agentoptions\"><code>&#x3C;AgentOptions></code></a></li>\n<li><code>agent</code> <a href=\"Dispatcher.md#class-dispatcher\"><code>&#x3C;Dispatcher></code></a> (optional) A custom agent to be encapsulated by the <code>MockAgent</code>. It must implement the <code>Agent</code> API (that is, expose a <code>dispatch</code>\nfunction). <strong>Default:</strong> a new <a href=\"Agent.md#class-agent\"><code>&#x3C;Agent></code></a> constructed from <code>options</code>.</li>\n<li><code>ignoreTrailingSlash</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#boolean_type\"><code>&#x3C;boolean></code></a> (optional) Whether trailing slashes in the\nrequest path are ignored when matching interceptors. <strong>Default:</strong> <code>false</code>.</li>\n<li><code>acceptNonStandardSearchParameters</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#boolean_type\"><code>&#x3C;boolean></code></a> (optional) Whether the matcher\nalso accepts URLs using non-standard search-parameter syntaxes, such as\nmulti-value items written with <code>[]</code> (for example <code>param[]=1&#x26;param[]=2</code>) or\ncomma-separated values (for example <code>param=1,2,3</code>). <strong>Default:</strong> <code>false</code>.</li>\n<li><code>enableCallHistory</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#boolean_type\"><code>&#x3C;boolean></code></a> (optional) Whether call history recording is\nenabled. See <a href=\"#mockagentgetcallhistory\"><code>mockAgent.getCallHistory()</code></a>. <strong>Default:</strong> <code>false</code>.</li>\n</ul>\n<pre><code class=\"language-mjs\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent()\n</code></pre>\n<pre><code class=\"language-mjs\">import { Agent, MockAgent } from 'undici'\n\nconst agent = new Agent()\n\nconst mockAgent = new MockAgent({ agent })\n</code></pre>",
                  "displayName": "Parameter: `MockAgentOptions`"
                }
              ]
            }
          ],
          "methods": [
            {
              "textRaw": "`mockAgent.get(origin)`",
              "name": "get",
              "type": "method",
              "meta": {
                "added": [
                  "v4.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`origin` {string|RegExp|Function} A matcher for the origin to retrieve. The function form has the signature `(origin) => boolean`.",
                      "name": "origin",
                      "type": "string|RegExp|Function",
                      "desc": "A matcher for the origin to retrieve. The function form has the signature `(origin) => boolean`."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {MockClient|MockPool}",
                    "name": "return",
                    "type": "MockClient|MockPool"
                  }
                }
              ],
              "desc": "<p>Creates and retrieves the mock dispatcher used to intercept requests for the\ngiven origin. When the <code>connections</code> option of the <code>MockAgent</code> is <code>1</code>, a\n<a href=\"MockClient.md#class-mockclient\"><code>&#x3C;MockClient></code></a> is returned; otherwise a <a href=\"MockPool.md#class-mockpool\"><code>&#x3C;MockPool></code></a> is returned. Subsequent calls\nwith the same origin return the same instance.</p>\n<p>The way <code>origin</code> is matched against incoming requests depends on its type:</p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">Matcher type</th>\n<th>Condition to pass</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"center\"><code>string</code></td>\n<td>Exact match against the value</td>\n</tr>\n<tr>\n<td align=\"center\"><code>RegExp</code></td>\n<td>The regular expression matches</td>\n</tr>\n<tr>\n<td align=\"center\"><code>Function</code></td>\n<td>The function returns <code>true</code></td>\n</tr>\n</tbody>\n</table>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nconst mockPool = mockAgent.get('http://localhost:3000')\nmockPool.intercept({ path: '/foo' }).reply(200, 'foo')\n\nconst { statusCode, body } = await request('http://localhost:3000/foo')\n\nconsole.log('response received', statusCode) // response received 200\n\nfor await (const data of body) {\n  console.log('data', data.toString('utf8')) // data foo\n}\n</code></pre>\n<pre><code class=\"language-mjs\">import { MockAgent, request } from 'undici'\n\nconst mockAgent = new MockAgent()\n\nconst mockPool = mockAgent.get('http://localhost:3000')\nmockPool.intercept({ path: '/foo' }).reply(200, 'foo')\n\nconst { statusCode, body } = await request('http://localhost:3000/foo', {\n  dispatcher: mockAgent\n})\n\nconsole.log('response received', statusCode) // response received 200\n\nfor await (const data of body) {\n  console.log('data', data.toString('utf8')) // data foo\n}\n</code></pre>\n<pre><code class=\"language-mjs\">import { MockAgent, request } from 'undici'\n\nconst mockAgent = new MockAgent({ connections: 1 })\n\nconst mockClient = mockAgent.get('http://localhost:3000')\nmockClient.intercept({ path: '/foo' }).reply(200, 'foo')\n\nconst { statusCode, body } = await request('http://localhost:3000/foo', {\n  dispatcher: mockClient\n})\n\nconsole.log('response received', statusCode) // response received 200\n\nfor await (const data of body) {\n  console.log('data', data.toString('utf8')) // data foo\n}\n</code></pre>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nconst mockPool = mockAgent.get(new RegExp('http://localhost:3000'))\nmockPool.intercept({ path: '/foo' }).reply(200, 'foo')\n\nconst { statusCode } = await request('http://localhost:3000/foo')\n\nconsole.log('response received', statusCode) // response received 200\n</code></pre>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nconst mockPool = mockAgent.get((origin) => origin === 'http://localhost:3000')\nmockPool.intercept({ path: '/foo' }).reply(200, 'foo')\n\nconst { statusCode } = await request('http://localhost:3000/foo')\n\nconsole.log('response received', statusCode) // response received 200\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.dispatch(options, handler)`",
              "name": "dispatch",
              "type": "method",
              "meta": {
                "added": [
                  "v4.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {AgentDispatchOptions}",
                      "name": "options",
                      "type": "AgentDispatchOptions"
                    },
                    {
                      "textRaw": "`handler` {DispatchHandler}",
                      "name": "handler",
                      "type": "DispatchHandler"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {boolean}",
                    "name": "return",
                    "type": "boolean"
                  }
                }
              ],
              "desc": "<p>Dispatches a mocked request. This implements\n<a href=\"Dispatcher.html#dispatcherdispatchoptions-handler\"><code>Dispatcher.dispatch()</code></a> for the encapsulated agent: it ensures the mock\ndispatcher for <code>options.origin</code> exists, records the call in the call history\nwhen enabled, and forwards the request to the underlying agent. It is normally\ninvoked indirectly through higher-level methods such as\n<a href=\"Dispatcher.html#dispatcherrequestoptions-callback\"><code>mockAgent.request()</code></a>.</p>\n<pre><code class=\"language-mjs\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent()\n\nconst mockPool = mockAgent.get('http://localhost:3000')\nmockPool.intercept({ path: '/foo' }).reply(200, 'foo')\n\nconst { statusCode, body } = await mockAgent.request({\n  origin: 'http://localhost:3000',\n  path: '/foo',\n  method: 'GET'\n})\n\nconsole.log('response received', statusCode) // response received 200\n\nfor await (const data of body) {\n  console.log('data', data.toString('utf8')) // data foo\n}\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.close()`",
              "name": "close",
              "type": "method",
              "meta": {
                "added": [
                  "v4.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Promise<void>} Resolves once the agent and its registered mock pools and clients have closed.",
                    "name": "return",
                    "type": "Promise<void>",
                    "desc": "Resolves once the agent and its registered mock pools and clients have closed."
                  }
                }
              ],
              "desc": "<p>Clears the call history, closes the encapsulated agent, and waits for all\nregistered mock pools and clients to close.</p>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nawait mockAgent.close()\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.deactivate()`",
              "name": "deactivate",
              "type": "method",
              "meta": {
                "added": [
                  "v4.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {undefined}",
                    "name": "return",
                    "type": "undefined"
                  }
                }
              ],
              "desc": "<p>Disables mocking on the <code>MockAgent</code>. While deactivated, requests are no longer\nintercepted.</p>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nmockAgent.deactivate()\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.activate()`",
              "name": "activate",
              "type": "method",
              "meta": {
                "added": [
                  "v4.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {undefined}",
                    "name": "return",
                    "type": "undefined"
                  }
                }
              ],
              "desc": "<p>Enables mocking on the <code>MockAgent</code>. A <code>MockAgent</code> is activated automatically\nwhen instantiated, so this method is only required after\n<a href=\"#mockagentdeactivate\"><code>mockAgent.deactivate()</code></a> has been called.</p>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nmockAgent.deactivate()\n// No mocking will occur\n\n// Later\nmockAgent.activate()\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.enableNetConnect([matcher])`",
              "name": "enableNetConnect",
              "type": "method",
              "meta": {
                "added": [
                  "v4.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`matcher` {string|RegExp|Function} (optional) A host matcher. When a string is used it should only contain the hostname and, optionally, the port. The function form has the signature `(host) => boolean`. When omitted, all non-matching requests are allowed to perform a real request.",
                      "name": "matcher",
                      "type": "string|RegExp|Function",
                      "desc": "(optional) A host matcher. When a string is used it should only contain the hostname and, optionally, the port. The function form has the signature `(host) => boolean`. When omitted, all non-matching requests are allowed to perform a real request.",
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {undefined}",
                    "name": "return",
                    "type": "undefined"
                  }
                }
              ],
              "desc": "<p>Defines host matchers so that requests that are not intercepted by a mock\ndispatcher are allowed to perform a real HTTP request. Calling this method\nmultiple times with a string appends each value to the list of allowed hosts.</p>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nmockAgent.enableNetConnect()\n\nawait request('http://example.com')\n// A real request is made\n</code></pre>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nmockAgent.enableNetConnect('example-1.com')\nmockAgent.enableNetConnect('example-2.com:8080')\n\nawait request('http://example-1.com')\n// A real request is made\n\nawait request('http://example-2.com:8080')\n// A real request is made\n\nawait request('http://example-3.com')\n// Will throw\n</code></pre>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nmockAgent.enableNetConnect(new RegExp('example.com'))\nmockAgent.enableNetConnect((host) => host === 'example.org')\n\nawait request('http://example.com')\n// A real request is made\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.disableNetConnect()`",
              "name": "disableNetConnect",
              "type": "method",
              "meta": {
                "added": [
                  "v4.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {undefined}",
                    "name": "return",
                    "type": "undefined"
                  }
                }
              ],
              "desc": "<p>Causes every request that is not matched by a mock interceptor to throw,\ndisallowing real HTTP requests.</p>\n<pre><code class=\"language-mjs\">import { MockAgent, request } from 'undici'\n\nconst mockAgent = new MockAgent()\n\nmockAgent.disableNetConnect()\n\nawait request('http://example.com')\n// Will throw\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.enableCallHistory()`",
              "name": "enableCallHistory",
              "type": "method",
              "meta": {
                "added": [
                  "v7.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {MockAgent} The same `MockAgent` instance, for chaining.",
                    "name": "return",
                    "type": "MockAgent",
                    "desc": "The same `MockAgent` instance, for chaining."
                  }
                }
              ],
              "desc": "<p>Enables call history recording. Once enabled, subsequent calls are registered\nand can be retrieved through <a href=\"#mockagentgetcallhistory\"><code>mockAgent.getCallHistory()</code></a>. Call history can\nalso be enabled at construction time with the <code>enableCallHistory</code> option.</p>\n<pre><code class=\"language-mjs\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent()\n\nmockAgent.enableCallHistory()\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.disableCallHistory()`",
              "name": "disableCallHistory",
              "type": "method",
              "meta": {
                "added": [
                  "v7.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {MockAgent} The same `MockAgent` instance, for chaining.",
                    "name": "return",
                    "type": "MockAgent",
                    "desc": "The same `MockAgent` instance, for chaining."
                  }
                }
              ],
              "desc": "<p>Disables call history recording. Subsequent calls are no longer registered.</p>\n<pre><code class=\"language-mjs\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent({ enableCallHistory: true })\n\nmockAgent.disableCallHistory()\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.getCallHistory()`",
              "name": "getCallHistory",
              "type": "method",
              "meta": {
                "added": [
                  "v7.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {MockCallHistory|undefined} The {MockCallHistory} instance, or `undefined` when call history is not enabled.",
                    "name": "return",
                    "type": "MockCallHistory|undefined",
                    "desc": "The {MockCallHistory} instance, or `undefined` when call history is not enabled."
                  }
                }
              ],
              "desc": "<p>Returns the call history instance, which records every request made through the\n<code>MockAgent</code> (whether intercepted or not). Call history is not enabled by\ndefault; enable it with the <code>enableCallHistory</code> option or\n<a href=\"#mockagentenablecallhistory\"><code>mockAgent.enableCallHistory()</code></a>.</p>\n<pre><code class=\"language-mjs\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent({ enableCallHistory: true })\nsetGlobalDispatcher(mockAgent)\n\nawait request('http://example.com', { query: { item: 1 } })\n\nmockAgent.getCallHistory()?.firstCall()\n// Returns\n// MockCallHistoryLog {\n//   body: undefined,\n//   headers: undefined,\n//   method: 'GET',\n//   origin: 'http://example.com',\n//   fullUrl: 'http://example.com/?item=1',\n//   path: '/',\n//   searchParams: { item: '1' },\n//   protocol: 'http:',\n//   host: 'example.com',\n//   port: ''\n// }\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.clearCallHistory()`",
              "name": "clearCallHistory",
              "type": "method",
              "meta": {
                "added": [
                  "v7.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {undefined}",
                    "name": "return",
                    "type": "undefined"
                  }
                }
              ],
              "desc": "<p>Clears the call history, deleting every recorded <a href=\"MockCallHistoryLog.md#class-mockcallhistorylog\"><code>&#x3C;MockCallHistoryLog></code></a> on the\n<a href=\"MockCallHistory.md#class-mockcallhistory\"><code>&#x3C;MockCallHistory></code></a> instance. It is a no-op when call history has never been\nenabled.</p>\n<pre><code class=\"language-mjs\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent({ enableCallHistory: true })\n\nmockAgent.clearCallHistory()\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.pendingInterceptors()`",
              "name": "pendingInterceptors",
              "type": "method",
              "meta": {
                "added": [
                  "v5.1.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {PendingInterceptor}[] A `PendingInterceptor` is a `MockDispatch` with an additional `origin` {string} property.",
                    "name": "return",
                    "type": "PendingInterceptor",
                    "desc": "[] A `PendingInterceptor` is a `MockDispatch` with an additional `origin` {string} property."
                  }
                }
              ],
              "desc": "<p>Returns the interceptors registered on the <code>MockAgent</code> that are still pending.\nAn interceptor is pending when it meets one of the following criteria:</p>\n<ul>\n<li>It is registered with neither <code>.times(&#x3C;number>)</code> nor <code>.persist()</code> and has not\nbeen invoked.</li>\n<li>It is persistent (registered with <code>.persist()</code>) and has not been invoked.</li>\n<li>It is registered with <code>.times(&#x3C;number>)</code> and has not been invoked <code>&#x3C;number></code>\ntimes.</li>\n</ul>\n<pre><code class=\"language-mjs\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent()\nmockAgent.disableNetConnect()\n\nmockAgent\n  .get('https://example.com')\n  .intercept({ method: 'GET', path: '/' })\n  .reply(200)\n\nconst pendingInterceptors = mockAgent.pendingInterceptors()\n// Returns [\n//   {\n//     timesInvoked: 0,\n//     times: 1,\n//     persist: false,\n//     consumed: false,\n//     pending: true,\n//     path: '/',\n//     method: 'GET',\n//     body: undefined,\n//     headers: undefined,\n//     data: {\n//       error: null,\n//       statusCode: 200,\n//       data: '',\n//       headers: {},\n//       trailers: {}\n//     },\n//     origin: 'https://example.com'\n//   }\n// ]\n</code></pre>"
            },
            {
              "textRaw": "`mockAgent.assertNoPendingInterceptors([options])`",
              "name": "assertNoPendingInterceptors",
              "type": "method",
              "meta": {
                "added": [
                  "v5.1.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`options` {Object} (optional)",
                      "name": "options",
                      "type": "Object",
                      "desc": "(optional)",
                      "options": [
                        {
                          "textRaw": "`pendingInterceptorsFormatter` {Object} An object exposing a `format(pendingInterceptors)` method used to render the pending interceptors in the thrown error message. **Default:** a built-in formatter that prints a table.",
                          "name": "pendingInterceptorsFormatter",
                          "type": "Object",
                          "default": "a built-in formatter that prints a table",
                          "desc": "An object exposing a `format(pendingInterceptors)` method used to render the pending interceptors in the thrown error message."
                        }
                      ],
                      "optional": true
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {undefined}",
                    "name": "return",
                    "type": "undefined"
                  }
                }
              ],
              "desc": "<p>Throws an <a href=\"Errors.md#class-undicierror\"><code>&#x3C;UndiciError></code></a> when the <code>MockAgent</code> has any pending interceptors. The\ncriteria for an interceptor being pending are the same as for\n<a href=\"#mockagentpendinginterceptors\"><code>mockAgent.pendingInterceptors()</code></a>.</p>\n<pre><code class=\"language-mjs\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent()\nmockAgent.disableNetConnect()\n\nmockAgent\n  .get('https://example.com')\n  .intercept({ method: 'GET', path: '/' })\n  .reply(200)\n\nmockAgent.assertNoPendingInterceptors()\n// Throws an UndiciError with the following message:\n//\n// 1 interceptor is pending:\n//\n// ┌─────────┬────────┬───────────────────────┬──────┬─────────────┬────────────┬─────────────┬───────────┐\n// │ (index) │ Method │        Origin         │ Path │ Status code │ Persistent │ Invocations │ Remaining │\n// ├─────────┼────────┼───────────────────────┼──────┼─────────────┼────────────┼─────────────┼───────────┤\n// │    0    │ 'GET'  │ 'https://example.com' │ '/'  │     200     │    '❌'    │      0      │     1     │\n// └─────────┴────────┴───────────────────────┴──────┴─────────────┴────────────┴─────────────┴───────────┘\n</code></pre>"
            }
          ],
          "properties": [
            {
              "textRaw": "Type: {boolean} `true` while mocking is active, `false` after `mockAgent.deactivate()` has been called.",
              "name": "isMockActive",
              "type": "boolean",
              "meta": {
                "added": [
                  "v5.3.0"
                ],
                "changes": []
              },
              "desc": "<p>A read-only property indicating whether mocking is currently active on the\n<code>MockAgent</code>.</p>\n<pre><code class=\"language-mjs\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent()\n\nconsole.log(mockAgent.isMockActive) // true\n\nmockAgent.deactivate()\n\nconsole.log(mockAgent.isMockActive) // false\n</code></pre>",
              "shortDesc": "`true` while mocking is active, `false` after `mockAgent.deactivate()` has been called."
            }
          ]
        }
      ]
    }
  ]
}