Dashboard › cli › Distillation
45772b7c-327f-47b9-8382-b674ae14663d["lore_tm_v1_v1ADS8Fjj6ANSKh0fs8ViGLEdxiE1Rbv_L-zuzURBM8"]
packages/cli/test/preload.ts polyfills globalThis.self in Node by assigning globalThis when self is undefined, because web-worker code such as grep-worker.js references self.onmessage.packages/cli/test/preload.ts loads test credentials from packages/cli/.env.local: it ignores blank/comment lines and lines without =, trims keys and values, removes matching single or double quotes, and only writes a value when process.env[key] is not already set, so existing environment variables take precedence.TEST_TMP_DIR recursively with force: true, recreates it, and performs a one-time migration that removes every $HOME entry whose name starts with .sentry-cli-test-; cleanup/listing errors are ignored for first-run and restricted-CI compatibility.packages/cli/test/preload.ts creates an isolated per-process directory at join(TEST_TMP_DIR, \preload-${process.pid}`)and setsprocess.env.SENTRY_CONFIG_DIRto it, matchingCONFIG_DIR_ENV_VARfromsrc/lib/config.ts`.SENTRY_DSN, SENTRY_AUTH_TOKEN, SENTRY_TOKEN, SENTRY_CLIENT_ID, SENTRY_URL, SENTRY_HOST, SENTRY_ORG, and SENTRY_PROJECT, while preserving SENTRY_TEST_* variables for E2E tests.SENTRY_AUTH_TOKEN a fake unit-test token so buildCommand’s auth guard passes; tests of unauthenticated behavior instead mock getAuthConfig to return undefined.SENTRY_CLI_NO_TELEMETRY="1" and SENTRY_CLI_NO_UPDATE_CHECK="1" to prevent Sentry SDK background activity, external calls, and process-liveness issues.packages/cli/test/preload.ts globally replaces fetch with mockFetch, which normalizes URL inputs through getUrlFromInput(), logs the unexpected URL and a mocking/credential warning to console.error, then throws Error(\Unmocked fetch call to: ${url}`); the assignment casts through unknownbecause Bun’s fetch type includespreconnect`.(globalThis as { __originalFetch?: typeof fetch }).__originalFetch so tests needing real fetch can restore it.testDir recursively on process exit; it also handles SIGINT and SIGTERM by calling process.exit(0).packages/cli/test/preload.ts extends Vitest’s expect with Bun-compatible custom matchers. Visible implementations include toStartWith(received, expected), based on received.startsWith(expected); toEndWith(received, expected), based on received.endsWith(expected); and toBeString(received), based on typeof received === "string".