test(mock): cover SnapshotAgent excludeUrls playback#5080
test(mock): cover SnapshotAgent excludeUrls playback#5080maruthang wants to merge 1 commit intonodejs:mainfrom
Conversation
Add a regression test for the SnapshotAgent playback-mode behaviour reported in nodejs#4663: a URL matched by an excludeUrls entry must pass through to the real network during playback instead of throwing "No snapshot found". The test covers both string and RegExp forms of excludeUrls, including a regexp that only matches during playback, so any future regression in the dispatch short-circuit is caught. Refs nodejs#4663 Signed-off-by: Maruthan G <maruthang4@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5080 +/- ##
=======================================
Coverage 93.10% 93.10%
=======================================
Files 110 110
Lines 35807 35807
=======================================
Hits 33339 33339
Misses 2468 2468 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
WHy is the test included in #4670 not enough? |
|
Fair point @mcollina — the Happy to close this if you'd prefer to keep the suite lean — the issue is already functionally closed by #4670. If you think the RegExp-in-playback case is worth pinning separately I can leave it, but otherwise just say the word and I'll close. |
|
Friendly nudge — approved by @metcoder95, all 35 checks green. Tests-only change covering the |
This relates to...
Fixes #4663
Rationale
Issue #4663 reported that
SnapshotAgentinplaybackmode threw "No snapshot found" for URLs matched byexcludeUrls, even though excluded URLs are meant to pass through to the real network.The underlying bug was already fixed on
mainby PR #4670 (commit5024d1b7), which routes excluded URLs throughkRealAgent.dispatchbeforefindSnapshotis consulted (seelib/mock/snapshot-agent.js:85-88). However, the issue was never formally closed and no regression test was added for this specific playback-mode path.This PR adds a focused regression test so the excludeUrls playback short-circuit cannot silently regress. It reproduces the exact scenario from the issue and also covers a RegExp pattern that only matches during playback, which exercises the dispatch branch end-to-end.
Changes
Add
test/mock/issue-4663.jswith two cases:excludeUrlsentry — excluded URL is fetched live during playback.excludeUrlsentry — excluded URL is fetched live during playback.Features
N/A
Bug Fixes
N/A — the bug itself was fixed in #4670. This PR adds regression coverage only.
Breaking Changes and Deprecations
N/A
Status
test/mock/issue-4663.js; allsnapshot-*andmock-*tests pass)