fix(test): silence "unexpected fetch call to" warnings in unit tests#716
Merged
fix(test): silence "unexpected fetch call to" warnings in unit tests#716
Conversation
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1579 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 95.36% 95.35% -0.01%
==========================================
Files 232 232 —
Lines 33941 33952 +11
Branches 0 0 —
==========================================
+ Hits 32365 32373 +8
- Misses 1576 1579 +3
- Partials 0 0 —Generated by Codecov Action |
Eliminate all 182 "unexpected fetch call to" warnings from the unit and isolated test suites. The warnings were caused by test code paths reaching the global fetch trap in test/preload.ts without proper mocking — tests passed because errors were caught internally, but console.error fired before the catch. Root causes across 11 test files: - Missing org region cache: tests called resolveEffectiveOrg without pre-populating setOrgRegion, triggering API fetches to discover region URLs (resolve-target-listing, span/view, project/create) - Fire-and-forget warmOrgCache: after successful login, warmOrgCache() calls listOrganizationsUncached() as a detached promise that outlives the test and spills warnings into subsequent test files (auth/login, login-reauth) - Resolution cascade fall-through: env var tests, SDK integration tests, and help-positional tests triggered DSN detection and directory inference when env vars were empty, making API calls on the fall-through path (resolve-target, index, help-positional, issue/utils) - Background version check: maybeCheckForUpdateInBackground() fired real fetches to GitHub API (version-check) - Missing per-test fetch mock: one test inside a describe block with save/restore lacked its own fetch mock (resolve-effective-org)
1cb11ab to
94c1d71
Compare
5 tasks
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
[TEST] Unexpected fetch call to:warnings from the unit and isolated test suitestest/preload.tsRoot Causes Fixed
setOrgRegion()inbeforeEachwarmOrgCache()listOrganizationsUncachedcwd: "/tmp"Ref: https://github.com/getsentry/cli/actions/runs/24265638656/job/70864771196