fix(mock): improve error message when intercepts are exhausted#4912
Merged
mcollina merged 1 commit intonodejs:mainfrom Mar 21, 2026
Merged
Conversation
When all mock intercepts for a request have been consumed, the error message now includes how many interceptors remain and how many were originally defined. This helps users understand that their intercepts were used up rather than misconfigured. Example: "Mock dispatch not matched for path '/foo': subsequent request to origin https://api.example.com was not allowed (net.connect disabled), 0 interceptor(s) remaining out of 3 defined" Fixes nodejs#2219 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4912 +/- ##
=======================================
Coverage 92.90% 92.90%
=======================================
Files 112 112
Lines 35638 35645 +7
=======================================
+ Hits 33108 33116 +8
+ Misses 2530 2529 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
metcoder95
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kTotalDispatchCountsymbol on the dispatches array, so the count persists even after consumed dispatches are cleaned upBefore:
After:
Fixes #2219
Test plan
should include intercept count in error when intercepts are exhaustedverifies the message includes counts after intercepts are consumed🤖 Generated with Claude Code