diff options
| author | Richie Foreman <[email protected]> | 2025-08-13 17:45:53 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-13 21:45:53 +0000 |
| commit | d6f74ea2f0a422c86daea2a06284e497db082a16 (patch) | |
| tree | fab51ccf375da7c7f7de46e2456f16ebac8fbc4c /packages/core/src/ide/detect-ide.test.ts | |
| parent | 501b78f3032d8e1d506b5e58d762a30a3593a500 (diff) | |
chore(telemetry): Add various surface detection to `determineSurface` for logging. (#6074)
Co-authored-by: christine betts <[email protected]>
Co-authored-by: Jacob Richman <[email protected]>
Co-authored-by: matt korwel <[email protected]>
Diffstat (limited to 'packages/core/src/ide/detect-ide.test.ts')
| -rw-r--r-- | packages/core/src/ide/detect-ide.test.ts | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/packages/core/src/ide/detect-ide.test.ts b/packages/core/src/ide/detect-ide.test.ts new file mode 100644 index 00000000..85249ad6 --- /dev/null +++ b/packages/core/src/ide/detect-ide.test.ts @@ -0,0 +1,68 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect, afterEach, vi } from 'vitest'; +import { detectIde, DetectedIde } from './detect-ide.js'; + +describe('detectIde', () => { + afterEach(() => { + vi.unstubAllEnvs(); + }); + + it.each([ + { + env: {}, + expected: DetectedIde.VSCode, + }, + { + env: { __COG_BASHRC_SOURCED: '1' }, + expected: DetectedIde.Devin, + }, + { + env: { REPLIT_USER: 'test' }, + expected: DetectedIde.Replit, + }, + { + env: { CURSOR_TRACE_ID: 'test' }, + expected: DetectedIde.Cursor, + }, + { + env: { CODESPACES: 'true' }, + expected: DetectedIde.Codespaces, + }, + { + env: { EDITOR_IN_CLOUD_SHELL: 'true' }, + expected: DetectedIde.CloudShell, + }, + { + env: { CLOUD_SHELL: 'true' }, + expected: DetectedIde.CloudShell, + }, + { + env: { TERM_PRODUCT: 'Trae' }, + expected: DetectedIde.Trae, + }, + { + env: { FIREBASE_DEPLOY_AGENT: 'true' }, + expected: DetectedIde.FirebaseStudio, + }, + { + env: { MONOSPACE_ENV: 'true' }, + expected: DetectedIde.FirebaseStudio, + }, + ])('detects the IDE for $expected', ({ env, expected }) => { + vi.stubEnv('TERM_PROGRAM', 'vscode'); + for (const [key, value] of Object.entries(env)) { + vi.stubEnv(key, value); + } + expect(detectIde()).toBe(expected); + }); + + it('returns undefined for non-vscode', () => { + vi.stubEnv('TERM_PROGRAM', 'definitely-not-vscode'); + expect(detectIde()).toBeUndefined(); + }); +}); |
