Skip to content

test(test-utils): Add Sentry CLI trace helpers as test-utils/cli - #24279

Draft
JPeer264 wants to merge 1 commit into
developfrom
jp/test-utils-sentry-cli-helpers
Draft

test(test-utils): Add Sentry CLI trace helpers as test-utils/cli#24279
JPeer264 wants to merge 1 commit into
developfrom
jp/test-utils-sentry-cli-helpers

Conversation

@JPeer264

Copy link
Copy Markdown
Member

Adds @sentry-internal/test-utils/cli, a helper module for E2E apps that send real data to Sentry and have to wait until it is queryable. It shells out to the sentry CLI (sentry trace view <org>/<project>/<trace> --json --fresh) instead of hand-rolling requests against the organization trace endpoint, and exposes findErrorInTrace, findSpanInTrace, fetchTrace, flattenTrace, traceTarget and EVENT_POLLING_OPTIONS.

Decisions:

  • The CLI itself is a dev dependency of the consuming app (the sentry package on npm), not of test-utils. The helper runs pnpm exec sentry in the app's working directory, which keeps the 15 MB CLI out of every other test app.
  • The helper hands E2E_TEST_AUTH_TOKEN to the CLI as SENTRY_AUTH_TOKEN and sets SENTRY_FORCE_ENV_TOKEN=1. Without the flag the CLI prefers a developer's stored login over the env token, so local runs would authenticate differently from CI.
  • --fresh bypasses the CLI's response cache, which would otherwise defeat polling.
  • Exit code 23 ("not found") means the trace has not landed yet. The auth exit codes and a 401 or 403 in the output fail immediately, because waiting never fixes a token that lacks org:read.
  • A separate subpath export instead of the root index, so the dependency on the CLI stays with the apps that opt in.
  • traceTarget returns the CLI target, so a test can log a sentry trace view ... line that is paste-able into a terminal when a CI run fails.

The first consumer is the Cloudflare send-to-sentry E2E app in the follow-up PR. react-send-to-sentry and node-express-send-to-sentry keep their fetch-based copies for now and can move over separately.

Part of #23610

🤖 Generated with Claude Code

Send-to-sentry E2E apps need to wait until their data is queryable in
Sentry. The new subpath export polls through the `sentry` CLI instead of
hand-rolled requests against the trace endpoint, and gives the tests a
paste-able `sentry trace view` command for debugging.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@JPeer264
JPeer264 added this pull request to stack #24281 September 10, 2026 06:29
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.91 kB - -
@sentry/browser - with treeshaking flags 27.21 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.1 kB - -
@sentry/browser (incl. Tracing) 50.27 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 50.28 kB - -
@sentry/browser (incl. Tracing, Profiling) 53.26 kB - -
@sentry/browser (incl. Tracing, Replay) 89.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 78.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 94.45 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 107.46 kB - -
@sentry/browser (incl. Feedback) 46.4 kB - -
@sentry/browser (incl. sendFeedback) 33.96 kB - -
@sentry/browser (incl. FeedbackAsync) 39.07 kB - -
@sentry/browser (incl. Metrics) 29.93 kB - -
@sentry/browser (incl. Logs) 30.19 kB - -
@sentry/browser (incl. Metrics & Logs) 30.86 kB - -
@sentry/react 30.66 kB - -
@sentry/react (incl. Tracing) 52.59 kB - -
@sentry/vue 36.15 kB - -
@sentry/vue (incl. Tracing) 52.53 kB - -
@sentry/svelte 28.93 kB - -
CDN Bundle 30.64 kB - -
CDN Bundle (incl. Tracing) 50.78 kB - -
CDN Bundle (incl. Logs, Metrics) 32.92 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 52.73 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.61 kB - -
CDN Bundle (incl. Tracing, Replay) 88.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 90.29 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 94.36 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 96.38 kB - -
CDN Bundle - uncompressed 90.72 kB - -
CDN Bundle (incl. Tracing) - uncompressed 151.68 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.3 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 157.64 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.71 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 271.25 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 277.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 284.95 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 290.89 kB - -
@sentry/nextjs (client) 54.91 kB - -
@sentry/sveltekit (client) 50.69 kB - -
@sentry/core/server 37.1 kB - -
@sentry/core/browser 13.66 kB - -
@sentry/node 128.07 kB +0.02% +23 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.61 kB - -
@sentry/node - without tracing 88.87 kB +0.03% +24 B 🔺
@sentry/node - without channel injection 107.3 kB +0.02% +21 B 🔺
@sentry/aws-serverless 97.26 kB +0.03% +23 B 🔺
@sentry/cloudflare (withSentry) - minified 202.48 kB - -
@sentry/cloudflare (withSentry) 504.19 kB - -

View base workflow run

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