diff options
| author | Allen Hutchison <[email protected]> | 2025-07-30 15:09:32 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-30 22:09:32 +0000 |
| commit | 498edb57abc9c047e2bd1ea828cc591618745bc4 (patch) | |
| tree | 5351d093415f1b3f80a3583f32154750cad5e10a /packages/cli/src | |
| parent | 7bc876654254d9a11d66135735ad10f1066ad213 (diff) | |
fix(testing): make ModelStatsDisplay snapshot test deterministic (#5236)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/cli/src')
| -rw-r--r-- | packages/cli/src/ui/components/ModelStatsDisplay.test.tsx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/packages/cli/src/ui/components/ModelStatsDisplay.test.tsx b/packages/cli/src/ui/components/ModelStatsDisplay.test.tsx index 57382d91..6adf2652 100644 --- a/packages/cli/src/ui/components/ModelStatsDisplay.test.tsx +++ b/packages/cli/src/ui/components/ModelStatsDisplay.test.tsx @@ -5,7 +5,7 @@ */ import { render } from 'ink-testing-library'; -import { describe, it, expect, vi } from 'vitest'; +import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest'; import { ModelStatsDisplay } from './ModelStatsDisplay.js'; import * as SessionContext from '../contexts/SessionContext.js'; import { SessionMetrics } from '../contexts/SessionContext.js'; @@ -38,6 +38,19 @@ const renderWithMockedStats = (metrics: SessionMetrics) => { }; describe('<ModelStatsDisplay />', () => { + beforeAll(() => { + vi.spyOn(Number.prototype, 'toLocaleString').mockImplementation(function ( + this: number, + ) { + // Use a stable 'en-US' format for test consistency. + return new Intl.NumberFormat('en-US').format(this); + }); + }); + + afterAll(() => { + vi.restoreAllMocks(); + }); + it('should render "no API calls" message when there are no active models', () => { const { lastFrame } = renderWithMockedStats({ models: {}, |
