Skip to content

test(e2e): use mock HTTP server instead of live API#78

Merged
BYK merged 6 commits intomainfrom
test/e2e-mock-server
Jan 27, 2026
Merged

test(e2e): use mock HTTP server instead of live API#78
BYK merged 6 commits intomainfrom
test/e2e-mock-server

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Jan 27, 2026

Summary

Replace E2E tests that hit the live Sentry API with isolated tests using a local mock HTTP server (Bun.serve).

Changes

  • Add mock server infrastructure (test/mocks/server.ts, routes.ts)
  • Add JSON fixtures for orgs, projects, issues, and events
  • Update all E2E tests to use mock server via SENTRY_URL env var
  • Use project-local .test-tmp directory instead of system /tmp
  • Fix runCli to use absolute bun path for subprocess spawning

Benefits

  • Tests no longer require SENTRY_TEST_AUTH_TOKEN or other env vars
  • Tests are deterministic (no live API variability)
  • Tests can run in CI without secrets
  • Faster execution (local mock vs network calls)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 27, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

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


New Features ✨

Issue

  • Add workspace-scoped alias cache by BYK in #52
  • Add short ID aliases for multi-project support by BYK in #31

Other

  • (api) Align with gh api and curl conventions by BYK in #60
  • (auth) Add press 'c' to copy URL during login flow by betegon in #58
  • (commands) Rename get commands to view and add -w browser flag by BYK in #53
  • Add explain and plan commands (Seer AI) by MathurAditya724 in #39
  • Add Sentry SDK for error tracking and usage telemetry by BYK in #63

Bug Fixes 🐛

Issue

  • Support short ID aliases in explain and plan commands by BYK in #74
  • Use correct fallback for unrecognized alias-suffix inputs by BYK in #72
  • Handle cross-org project slug collisions in alias generation by BYK in #62
  • Use org-scoped endpoint for latest event + enhanced display by betegon in #40

Other

  • (api) Use query params for --field with GET requests by BYK in #59

Documentation 📚

  • (issue) Update list command tips to reference view instead of get by BYK in #73
  • (readme) Add installation section by betegon in #65
  • Update command references from 'get' to 'view' and document -w flag by BYK in #54

Internal Changes 🔧

  • (release) Fix changelog-preview permissions by BYK in #41
  • Rename config folder from .sentry-cli-next to .sentry by BYK in #50

Other

  • test(e2e): use mock HTTP server instead of live API by BYK in #78

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 27, 2026

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 1662 uncovered lines.
✅ Project coverage is 64.65%. Comparing base (base) to head (head).

Files with missing lines (22)
File Patch % Lines
human.ts 18.35% ⚠️ 672 Missing
resolve-target.ts 18.67% ⚠️ 257 Missing
oauth.ts 21.71% ⚠️ 202 Missing
resolver.ts 3.23% ⚠️ 120 Missing
errors.ts 5.94% ⚠️ 95 Missing
api-client.ts 73.48% ⚠️ 74 Missing
api.ts 89.78% ⚠️ 47 Missing
seer.ts 75.54% ⚠️ 45 Missing
errors.ts 73.17% ⚠️ 33 Missing
seer.ts 77.04% ⚠️ 31 Missing
preload.ts 39.02% ⚠️ 25 Missing
detector.ts 87.79% ⚠️ 16 Missing
cache.ts 76.27% ⚠️ 14 Missing
telemetry.ts 89.87% ⚠️ 8 Missing
config.ts 97.11% ⚠️ 7 Missing
index.ts 95.06% ⚠️ 4 Missing
colors.ts 91.84% ⚠️ 4 Missing
env-file.ts 97.17% ⚠️ 3 Missing
alias.ts 98.56% ⚠️ 2 Missing
utils.ts 99.17% ⚠️ 1 Missing
java.ts 97.22% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    63.99%    64.65%    +0.66%
==========================================
  Files           40        39        -1
  Lines         4787      4702       -85
  Branches         0         0         —
==========================================
+ Hits          3063      3040       -23
- Misses        1724      1662       -62
- Partials         0         0         —

Generated by Codecov Action

Replace E2E tests that hit the live Sentry API with isolated tests using a local mock HTTP server (Bun.serve).

- Add mock server infrastructure (test/mocks/server.ts, routes.ts)
- Add JSON fixtures for orgs, projects, issues, and events
- Update all E2E tests to use mock server via SENTRY_URL env var
- Use project-local .test-tmp directory instead of system /tmp
- Fix runCli to use absolute bun path for subprocess spawning

Tests no longer require SENTRY_TEST_AUTH_TOKEN or other env vars.
@BYK BYK force-pushed the test/e2e-mock-server branch from 7242767 to 9b5d13f Compare January 27, 2026 00:41
@BYK BYK marked this pull request as ready for review January 27, 2026 00:45
BYK added 2 commits January 27, 2026 01:00
Add createE2EContext() helper that returns a run() function with
the mock server URL and config directory pre-configured in env vars.
This eliminates repetitive env block declarations across all E2E tests.
@BYK BYK requested a review from betegon January 27, 2026 01:03
BYK added 2 commits January 27, 2026 01:11
Add ctx.setAuthToken() method to E2EContext that writes directly to the
context's config directory. This avoids the race condition where parallel
test files would mutate the shared process.env[CONFIG_DIR_ENV_VAR], causing
setAuthToken() calls to write tokens to the wrong config directory.

All E2E tests now use ctx.setAuthToken() instead of the global function,
and no longer need to set process.env[CONFIG_DIR_ENV_VAR] in beforeEach.
… support

- Disable telemetry in E2E tests (SENTRY_CLI_NO_TELEMETRY=1) to avoid
  3-second flush timeout per CLI invocation
- Support SENTRY_CLI_BINARY env var to run tests against pre-built binary
- Split CI into test-unit (fast, runs early) and test-e2e (uses built binary)
- Add test:unit script to run only unit tests
- E2E tests now run in ~16s locally (down from ~150s)

In CI, E2E tests run after binary build using the actual distributed
binary, providing better validation of the production artifact.
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@BYK BYK merged commit 930739c into main Jan 27, 2026
16 checks passed
@BYK BYK deleted the test/e2e-mock-server branch January 27, 2026 07:37
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