test(e2e): use mock HTTP server instead of live API#78
Merged
Conversation
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Issue
Other
Bug Fixes 🐛Issue
Other
Documentation 📚
Internal Changes 🔧
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 1662 uncovered lines. Files with missing lines (22)
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.
7242767 to
9b5d13f
Compare
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.
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.
Contributor
There was a problem hiding this comment.
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.
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
Replace E2E tests that hit the live Sentry API with isolated tests using a local mock HTTP server (Bun.serve).
Changes
test/mocks/server.ts,routes.ts)SENTRY_URLenv var.test-tmpdirectory instead of system/tmprunClito use absolute bun path for subprocess spawningBenefits
SENTRY_TEST_AUTH_TOKENor other env vars