{
  "type": "module",
  "source": "doc/api/api-mockagent.md",
  "modules": [
    {
      "textRaw": "Class: MockAgent",
      "name": "class:_mockagent",
      "type": "module",
      "desc": "<p>Extends: <code>undici.Dispatcher</code></p>\n<p>A mocked Agent class that implements the Agent API. It allows one to intercept HTTP requests made through undici and return mocked responses instead.</p>",
      "signatures": [
        {
          "textRaw": "`new MockAgent([options])`",
          "name": "MockAgent",
          "type": "ctor",
          "params": [
            {
              "name": "options",
              "optional": true
            }
          ],
          "desc": "<p>Arguments:</p>\n<ul>\n<li><strong>options</strong> <code>MockAgentOptions</code> (optional) - It extends the <code>Agent</code> options.</li>\n</ul>\n<p>Returns: <code>MockAgent</code></p>",
          "modules": [
            {
              "textRaw": "Parameter: `MockAgentOptions`",
              "name": "parameter:_`mockagentoptions`",
              "type": "module",
              "desc": "<p>Extends: <a href=\"/docs/docs/api/Agent.html#parameter-agentoptions\"><code>AgentOptions</code></a></p>\n<ul>\n<li>\n<p><strong>agent</strong> <code>Agent</code> (optional) - Default: <code>new Agent([options])</code> - a custom agent encapsulated by the MockAgent.</p>\n</li>\n<li>\n<p><strong>ignoreTrailingSlash</strong> <code>boolean</code> (optional) - Default: <code>false</code> - set the default value for <code>ignoreTrailingSlash</code> for interceptors.</p>\n</li>\n<li>\n<p><strong>acceptNonStandardSearchParameters</strong> <code>boolean</code> (optional) - Default: <code>false</code> - set to <code>true</code> if the matcher should also accept non standard search parameters such as multi-value items specified with <code>[]</code> (e.g. <code>param[]=1&#x26;param[]=2&#x26;param[]=3</code>) and multi-value items which values are comma separated (e.g. <code>param=1,2,3</code>).</p>\n</li>\n</ul>",
              "displayName": "Parameter: `MockAgentOptions`"
            },
            {
              "textRaw": "Example - Basic MockAgent instantiation",
              "name": "example_-_basic_mockagent_instantiation",
              "type": "module",
              "desc": "<p>This will instantiate the MockAgent. It will not do anything until registered as the agent to use with requests and mock interceptions are added.</p>\n<pre><code class=\"language-js\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent()\n</code></pre>",
              "displayName": "Example - Basic MockAgent instantiation"
            },
            {
              "textRaw": "Example - Basic MockAgent instantiation with custom agent",
              "name": "example_-_basic_mockagent_instantiation_with_custom_agent",
              "type": "module",
              "desc": "<pre><code class=\"language-js\">import { Agent, MockAgent } from 'undici'\n\nconst agent = new Agent()\n\nconst mockAgent = new MockAgent({ agent })\n</code></pre>",
              "displayName": "Example - Basic MockAgent instantiation with custom agent"
            }
          ]
        }
      ],
      "modules": [
        {
          "textRaw": "Instance Methods",
          "name": "instance_methods",
          "type": "module",
          "methods": [
            {
              "textRaw": "`MockAgent.get(origin)`",
              "name": "get",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "origin"
                    }
                  ]
                }
              ],
              "desc": "<p>This method creates and retrieves MockPool or MockClient instances which can then be used to intercept HTTP requests. If the number of connections on the mock agent is set to 1, a MockClient instance is returned. Otherwise a MockPool instance is returned.</p>\n<p>For subsequent <code>MockAgent.get</code> calls on the same origin, the same mock instance will be returned.</p>\n<p>Arguments:</p>\n<ul>\n<li><strong>origin</strong> <code>string | RegExp | (value) => boolean</code> - a matcher for the pool origin to be retrieved from the MockAgent.</li>\n</ul>\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 string</td>\n</tr>\n<tr>\n<td align=\"center\"><code>RegExp</code></td>\n<td>Regex must pass</td>\n</tr>\n<tr>\n<td align=\"center\"><code>Function</code></td>\n<td>Function must return true</td>\n</tr>\n</tbody>\n</table>\n<p>Returns: <code>MockClient | MockPool</code>.</p>\n<table>\n<thead>\n<tr>\n<th><code>MockAgentOptions</code></th>\n<th>Mock instance returned</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>connections === 1</code></td>\n<td><code>MockClient</code></td>\n</tr>\n<tr>\n<td><code>connections</code> > <code>1</code></td>\n<td><code>MockPool</code></td>\n</tr>\n</tbody>\n</table>",
              "modules": [
                {
                  "textRaw": "Example - Basic Mocked Request",
                  "name": "example_-_basic_mocked_request",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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>",
                  "displayName": "Example - Basic Mocked Request"
                },
                {
                  "textRaw": "Example - Basic Mocked Request with local mock agent dispatcher",
                  "name": "example_-_basic_mocked_request_with_local_mock_agent_dispatcher",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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 {\n  statusCode,\n  body\n} = await request('http://localhost:3000/foo', { dispatcher: mockAgent })\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>",
                  "displayName": "Example - Basic Mocked Request with local mock agent dispatcher"
                },
                {
                  "textRaw": "Example - Basic Mocked Request with local mock pool dispatcher",
                  "name": "example_-_basic_mocked_request_with_local_mock_pool_dispatcher",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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 {\n  statusCode,\n  body\n} = await request('http://localhost:3000/foo', { dispatcher: mockPool })\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>",
                  "displayName": "Example - Basic Mocked Request with local mock pool dispatcher"
                },
                {
                  "textRaw": "Example - Basic Mocked Request with local mock client dispatcher",
                  "name": "example_-_basic_mocked_request_with_local_mock_client_dispatcher",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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 {\n  statusCode,\n  body\n} = await request('http://localhost:3000/foo', { dispatcher: mockClient })\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>",
                  "displayName": "Example - Basic Mocked Request with local mock client dispatcher"
                },
                {
                  "textRaw": "Example - Basic Mocked requests with multiple intercepts",
                  "name": "example_-_basic_mocked_requests_with_multiple_intercepts",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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')\nmockPool.intercept({ path: '/hello'}).reply(200, 'hello')\n\nconst result1 = await request('http://localhost:3000/foo')\n\nconsole.log('response received', result1.statusCode) // response received 200\n\nfor await (const data of result1.body) {\n  console.log('data', data.toString('utf8')) // data foo\n}\n\nconst result2 = await request('http://localhost:3000/hello')\n\nconsole.log('response received', result2.statusCode) // response received 200\n\nfor await (const data of result2.body) {\n  console.log('data', data.toString('utf8')) // data hello\n}\n</code></pre>",
                  "displayName": "Example - Basic Mocked requests with multiple intercepts"
                },
                {
                  "textRaw": "Example - Mock different requests within the same file",
                  "name": "example_-_mock_different_requests_within_the_same_file",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">const { MockAgent, setGlobalDispatcher } = require('undici');\nconst agent = new MockAgent();\nagent.disableNetConnect();\nsetGlobalDispatcher(agent);\ndescribe('Test', () => {\n  it('200', async () => {\n    const mockAgent = agent.get('http://test.com');\n    // your test\n  });\n  it('200', async () => {\n    const mockAgent = agent.get('http://testing.com');\n    // your test\n  });\n});\n</code></pre>",
                  "displayName": "Example - Mock different requests within the same file"
                },
                {
                  "textRaw": "Example - Mocked request with query body, headers and trailers",
                  "name": "example_-_mocked_request_with_query_body,_headers_and_trailers",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nconst mockPool = mockAgent.get('http://localhost:3000')\n\nmockPool.intercept({\n  path: '/foo?hello=there&#x26;see=ya',\n  method: 'POST',\n  body: 'form1=data1&#x26;form2=data2'\n}).reply(200, { foo: 'bar' }, {\n  headers: { 'content-type': 'application/json' },\n  trailers: { 'Content-MD5': 'test' }\n})\n\nconst {\n  statusCode,\n  headers,\n  trailers,\n  body\n} = await request('http://localhost:3000/foo?hello=there&#x26;see=ya', {\n  method: 'POST',\n  body: 'form1=data1&#x26;form2=data2'\n})\n\nconsole.log('response received', statusCode) // response received 200\nconsole.log('headers', headers) // { 'content-type': 'application/json' }\n\nfor await (const data of body) {\n  console.log('data', data.toString('utf8')) // '{\"foo\":\"bar\"}'\n}\n\nconsole.log('trailers', trailers) // { 'content-md5': 'test' }\n</code></pre>",
                  "displayName": "Example - Mocked request with query body, headers and trailers"
                },
                {
                  "textRaw": "Example - Mocked request with origin regex",
                  "name": "example_-_mocked_request_with_origin_regex",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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 {\n  statusCode,\n  body\n} = 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>",
                  "displayName": "Example - Mocked request with origin regex"
                },
                {
                  "textRaw": "Example - Mocked request with origin function",
                  "name": "example_-_mocked_request_with_origin_function",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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 {\n  statusCode,\n  body\n} = 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>",
                  "displayName": "Example - Mocked request with origin function"
                }
              ]
            },
            {
              "textRaw": "`MockAgent.close()`",
              "name": "close",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Closes the mock agent and waits for registered mock pools and clients to also close before resolving.</p>\n<p>Returns: <code>Promise&#x3C;void></code></p>",
              "modules": [
                {
                  "textRaw": "Example - clean up after tests are complete",
                  "name": "example_-_clean_up_after_tests_are_complete",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">import { MockAgent, setGlobalDispatcher } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nawait mockAgent.close()\n</code></pre>",
                  "displayName": "Example - clean up after tests are complete"
                }
              ]
            },
            {
              "textRaw": "`MockAgent.dispatch(options, handlers)`",
              "name": "dispatch",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "options"
                    },
                    {
                      "name": "handlers"
                    }
                  ]
                }
              ],
              "desc": "<p>Implements <a href=\"/docs/docs/api/Agent.html#parameter-agentdispatchoptions\"><code>Agent.dispatch(options, handlers)</code></a>.</p>"
            },
            {
              "textRaw": "`MockAgent.request(options[, callback])`",
              "name": "request",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "options"
                    },
                    {
                      "name": "callback",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>See <a href=\"/docs/docs/api/Dispatcher.html#dispatcherrequestoptions-callback\"><code>Dispatcher.request(options [, callback])</code></a>.</p>",
              "modules": [
                {
                  "textRaw": "Example - MockAgent request",
                  "name": "example_-_mockagent_request",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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 {\n  statusCode,\n  body\n} = 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>",
                  "displayName": "Example - MockAgent request"
                }
              ]
            },
            {
              "textRaw": "`MockAgent.deactivate()`",
              "name": "deactivate",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This method disables mocking in MockAgent.</p>\n<p>Returns: <code>void</code></p>",
              "modules": [
                {
                  "textRaw": "Example - Deactivate Mocking",
                  "name": "example_-_deactivate_mocking",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">import { MockAgent, setGlobalDispatcher } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nmockAgent.deactivate()\n</code></pre>",
                  "displayName": "Example - Deactivate Mocking"
                }
              ]
            },
            {
              "textRaw": "`MockAgent.activate()`",
              "name": "activate",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This method enables mocking in a MockAgent instance. When instantiated, a MockAgent is automatically activated. Therefore, this method is only effective after <code>MockAgent.deactivate</code> has been called.</p>\n<p>Returns: <code>void</code></p>",
              "modules": [
                {
                  "textRaw": "Example - Activate Mocking",
                  "name": "example_-_activate_mocking",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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>",
                  "displayName": "Example - Activate Mocking"
                }
              ]
            },
            {
              "textRaw": "`MockAgent.enableNetConnect([host])`",
              "name": "enableNetConnect",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "host",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>When requests are not matched in a MockAgent intercept, a real HTTP request is attempted. We can control this further through the use of <code>enableNetConnect</code>. This is achieved by defining host matchers so only matching requests will be attempted.</p>\n<p>When using a string, it should only include the <strong>hostname and optionally, the port</strong>. In addition, calling this method multiple times with a string will allow all HTTP requests that match these values.</p>\n<p>Arguments:</p>\n<ul>\n<li><strong>host</strong> <code>string | RegExp | (value) => boolean</code> - (optional)</li>\n</ul>\n<p>Returns: <code>void</code></p>",
              "modules": [
                {
                  "textRaw": "Example - Allow all non-matching urls to be dispatched in a real HTTP request",
                  "name": "example_-_allow_all_non-matching_urls_to_be_dispatched_in_a_real_http_request",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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>",
                  "displayName": "Example - Allow all non-matching urls to be dispatched in a real HTTP request"
                },
                {
                  "textRaw": "Example - Allow requests matching a host string to make real requests",
                  "name": "example_-_allow_requests_matching_a_host_string_to_make_real_requests",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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>",
                  "displayName": "Example - Allow requests matching a host string to make real requests"
                },
                {
                  "textRaw": "Example - Allow requests matching a host regex to make real requests",
                  "name": "example_-_allow_requests_matching_a_host_regex_to_make_real_requests",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nmockAgent.enableNetConnect(new RegExp('example.com'))\n\nawait request('http://example.com')\n// A real request is made\n</code></pre>",
                  "displayName": "Example - Allow requests matching a host regex to make real requests"
                },
                {
                  "textRaw": "Example - Allow requests matching a host function to make real requests",
                  "name": "example_-_allow_requests_matching_a_host_function_to_make_real_requests",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">import { MockAgent, setGlobalDispatcher, request } from 'undici'\n\nconst mockAgent = new MockAgent()\nsetGlobalDispatcher(mockAgent)\n\nmockAgent.enableNetConnect((value) => value === 'example.com')\n\nawait request('http://example.com')\n// A real request is made\n</code></pre>",
                  "displayName": "Example - Allow requests matching a host function to make real requests"
                }
              ]
            },
            {
              "textRaw": "`MockAgent.disableNetConnect()`",
              "name": "disableNetConnect",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This method causes all requests to throw when requests are not matched in a MockAgent intercept.</p>\n<p>Returns: <code>void</code></p>",
              "modules": [
                {
                  "textRaw": "Example - Disable all non-matching requests by throwing an error for each",
                  "name": "example_-_disable_all_non-matching_requests_by_throwing_an_error_for_each",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">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>",
                  "displayName": "Example - Disable all non-matching requests by throwing an error for each"
                }
              ]
            },
            {
              "textRaw": "`MockAgent.pendingInterceptors()`",
              "name": "pendingInterceptors",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>This method returns any pending interceptors registered on a mock agent. A pending interceptor meets one of the following criteria:</p>\n<ul>\n<li>Is registered with neither <code>.times(&#x3C;number>)</code> nor <code>.persist()</code>, and has not been invoked;</li>\n<li>Is persistent (i.e., registered with <code>.persist()</code>) and has not been invoked;</li>\n<li>Is registered with <code>.times(&#x3C;number>)</code> and has not been invoked <code>&#x3C;number></code> of times.</li>\n</ul>\n<p>Returns: <code>PendingInterceptor[]</code> (where <code>PendingInterceptor</code> is a <code>MockDispatch</code> with an additional <code>origin: string</code>)</p>",
              "modules": [
                {
                  "textRaw": "Example - List all pending interceptors",
                  "name": "example_-_list_all_pending_interceptors",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">const agent = new MockAgent()\nagent.disableNetConnect()\n\nagent\n  .get('https://example.com')\n  .intercept({ method: 'GET', path: '/' })\n  .reply(200)\n\nconst pendingInterceptors = agent.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>",
                  "displayName": "Example - List all pending interceptors"
                }
              ]
            },
            {
              "textRaw": "`MockAgent.assertNoPendingInterceptors([options])`",
              "name": "assertNoPendingInterceptors",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "options",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>This method throws if the mock agent has any pending interceptors. A pending interceptor meets one of the following criteria:</p>\n<ul>\n<li>Is registered with neither <code>.times(&#x3C;number>)</code> nor <code>.persist()</code>, and has not been invoked;</li>\n<li>Is persistent (i.e., registered with <code>.persist()</code>) and has not been invoked;</li>\n<li>Is registered with <code>.times(&#x3C;number>)</code> and has not been invoked <code>&#x3C;number></code> of times.</li>\n</ul>",
              "modules": [
                {
                  "textRaw": "Example - Check that there are no pending interceptors",
                  "name": "example_-_check_that_there_are_no_pending_interceptors",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">const agent = new MockAgent()\nagent.disableNetConnect()\n\nagent\n  .get('https://example.com')\n  .intercept({ method: 'GET', path: '/' })\n  .reply(200)\n\nagent.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>",
                  "displayName": "Example - Check that there are no pending interceptors"
                },
                {
                  "textRaw": "Example - access call history on MockAgent",
                  "name": "example_-_access_call_history_on_mockagent",
                  "type": "module",
                  "desc": "<p>You can register every call made within a MockAgent to be able to retrieve the body, headers and so on.</p>\n<p>This is not enabled by default.</p>\n<pre><code class=\"language-js\">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>",
                  "displayName": "Example - access call history on MockAgent"
                },
                {
                  "textRaw": "Example - clear call history",
                  "name": "example_-_clear_call_history",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">const mockAgent = new MockAgent()\n\nmockAgent.clearCallHistory()\n</code></pre>",
                  "displayName": "Example - clear call history"
                },
                {
                  "textRaw": "Example - call history instance class method",
                  "name": "example_-_call_history_instance_class_method",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">const mockAgent = new MockAgent()\n\nconst mockAgentHistory = mockAgent.getCallHistory()\n\nmockAgentHistory?.calls() // returns an array of MockCallHistoryLogs\nmockAgentHistory?.firstCall() // returns the first MockCallHistoryLogs or undefined\nmockAgentHistory?.lastCall() // returns the last MockCallHistoryLogs or undefined\nmockAgentHistory?.nthCall(3) // returns the third MockCallHistoryLogs or undefined\nmockAgentHistory?.filterCalls({ path: '/endpoint', hash: '#hash-value' }) // returns an Array of MockCallHistoryLogs WHERE path === /endpoint OR hash === #hash-value\nmockAgentHistory?.filterCalls({ path: '/endpoint', hash: '#hash-value' }, { operator: 'AND' }) // returns an Array of MockCallHistoryLogs WHERE path === /endpoint AND hash === #hash-value\nmockAgentHistory?.filterCalls(/\"data\": \"{}\"/) // returns an Array of MockCallHistoryLogs where any value match regexp\nmockAgentHistory?.filterCalls('application/json') // returns an Array of MockCallHistoryLogs where any value === 'application/json'\nmockAgentHistory?.filterCalls((log) => log.path === '/endpoint') // returns an Array of MockCallHistoryLogs when given function returns true\nmockAgentHistory?.clear() // clear the history\n</code></pre>",
                  "displayName": "Example - call history instance class method"
                }
              ]
            }
          ],
          "displayName": "Instance Methods"
        }
      ],
      "displayName": "Class: MockAgent"
    }
  ]
}