Skip to content

docs: clarify MockAgent pool usage#5542

Merged
mcollina merged 1 commit into
nodejs:mainfrom
vibhor-aggr:docs/mockagent-pool-usage
Jul 11, 2026
Merged

docs: clarify MockAgent pool usage#5542
mcollina merged 1 commit into
nodejs:mainfrom
vibhor-aggr:docs/mockagent-pool-usage

Conversation

@vibhor-aggr

Copy link
Copy Markdown
Contributor

Summary

Closes #996.

Clarifies that setGlobalDispatcher(mockAgent) only affects Undici APIs that use the global dispatcher and does not monkeypatch separately constructed Pool or Client instances. Adds a small example showing the recommended testing pattern: pass the MockPool returned by mockAgent.get(origin) into code that accepts a pool.

Verification

PATH=/mnt/TBT_DATA/nipun/work/tasks/earn-100-legal/workspace/toolchains/node/node-v24.16.0-linux-x64/bin:$PATH npm run lint
PATH=/mnt/TBT_DATA/nipun/work/tasks/earn-100-legal/workspace/toolchains/node/node-v24.16.0-linux-x64/bin:$PATH node --input-type=module <new MockPool example>
git diff --check

Results: lint passed, the MockPool example returned 200, and diff check passed.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.45%. Comparing base (c7c7e7f) to head (9126497).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5542   +/-   ##
=======================================
  Coverage   93.45%   93.45%           
=======================================
  Files         110      110           
  Lines       37376    37376           
=======================================
+ Hits        34928    34930    +2     
+ Misses       2448     2446    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina
mcollina merged commit 8738b73 into nodejs:main Jul 11, 2026
36 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MockAgent don't intercept Pool requests

3 participants