Skip to content

fix(test): silence "unexpected fetch call to" warnings in unit tests#716

Merged
BYK merged 1 commit intomainfrom
fix/test-fetch-warnings
Apr 11, 2026
Merged

fix(test): silence "unexpected fetch call to" warnings in unit tests#716
BYK merged 1 commit intomainfrom
fix/test-fetch-warnings

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 11, 2026

Summary

  • Eliminate all 182 [TEST] Unexpected fetch call to: warnings from the unit and isolated test suites
  • Fix incomplete fetch mocking across 11 test files that allowed code paths to reach the global fetch trap in test/preload.ts
  • All 4797 tests continue to pass with zero warnings

Root Causes Fixed

Category Files Fix
Missing org region cache resolve-target-listing, span/view, project/create Added setOrgRegion() in beforeEach
Fire-and-forget warmOrgCache() auth/login, login-reauth Spied on listOrganizationsUncached
Resolution cascade fall-through resolve-target, index, help-positional, issue/utils Added silent fetch mocks or cwd: "/tmp"
Background version check version-check Added fetch mock for GitHub API
Missing per-test fetch mock resolve-effective-org Added 401 mock for unauthenticated test

Ref: https://github.com/getsentry/cli/actions/runs/24265638656/job/70864771196

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 11, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (build) Normalize Windows backslash paths for sourcemap resolution by BYK in #714
  • (dashboard) Guard sort param by dataset in widget table queries by BYK in #715
  • (test) Silence "unexpected fetch call to" warnings in unit tests by BYK in #716

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 11, 2026

Codecov Results 📊

134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1579 uncovered lines.
❌ Project coverage is 95.35%. Comparing base (base) to head (head).

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

@BYK BYK marked this pull request as ready for review April 11, 2026 00:20
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)
@BYK BYK force-pushed the fix/test-fetch-warnings branch from 1cb11ab to 94c1d71 Compare April 11, 2026 00:25
@BYK BYK merged commit 07957df into main Apr 11, 2026
25 checks passed
@BYK BYK deleted the fix/test-fetch-warnings branch April 11, 2026 00:33
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.

1 participant