test(mock): cover SnapshotAgent excludeUrls playback#5080
Open
maruthang wants to merge 1 commit intonodejs:mainfrom
Open
test(mock): cover SnapshotAgent excludeUrls playback#5080maruthang wants to merge 1 commit intonodejs:mainfrom
maruthang 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:
|
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.
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)