diff --git a/package-lock.json b/package-lock.json index caacc4419..3103dc91a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,6 +79,7 @@ "node-pty": "^1.1.0", "prettier": "^3.7.4", "secretlint": "^12.2.0", + "strip-ansi": "^7.2.0", "tsx": "^4.21.0", "typescript": "^5", "typescript-eslint": "^8.50.1", diff --git a/package.json b/package.json index 1ab3763c8..a5a5de9f2 100644 --- a/package.json +++ b/package.json @@ -143,6 +143,7 @@ "node-pty": "^1.1.0", "prettier": "^3.7.4", "secretlint": "^12.2.0", + "strip-ansi": "^7.2.0", "tsx": "^4.21.0", "typescript": "^5", "typescript-eslint": "^8.50.1", diff --git a/src/cli/tui/components/__tests__/DeployStatus.test.tsx b/src/cli/tui/components/__tests__/DeployStatus.test.tsx index fedca8e1a..b661ec13c 100644 --- a/src/cli/tui/components/__tests__/DeployStatus.test.tsx +++ b/src/cli/tui/components/__tests__/DeployStatus.test.tsx @@ -2,6 +2,7 @@ import type { DeployMessage } from '../../../cdk/toolkit-lib/index.js'; import { DeployStatus } from '../DeployStatus.js'; import { render } from 'ink-testing-library'; import React from 'react'; +import stripAnsi from 'strip-ansi'; import { describe, expect, it } from 'vitest'; function makeMsg( @@ -28,7 +29,7 @@ describe('DeployStatus', () => { it('shows "Deploying to AWS" when not complete', () => { const { lastFrame } = render(); - expect(lastFrame()).toContain('Deploying to AWS'); + expect(stripAnsi(lastFrame()!)).toContain('Deploying to AWS'); }); it('shows success message when complete without error', () => { @@ -90,7 +91,7 @@ describe('DeployStatus', () => { const { lastFrame } = render(); // Should show deploying text but no resource lines - expect(lastFrame()).toContain('Deploying to AWS'); + expect(stripAnsi(lastFrame()!)).toContain('Deploying to AWS'); expect(lastFrame()).not.toContain('Some general info'); }); diff --git a/src/cli/tui/components/__tests__/LogPanel.test.tsx b/src/cli/tui/components/__tests__/LogPanel.test.tsx index e7e445e48..28003ed84 100644 --- a/src/cli/tui/components/__tests__/LogPanel.test.tsx +++ b/src/cli/tui/components/__tests__/LogPanel.test.tsx @@ -2,6 +2,7 @@ import type { LogEntry } from '../LogPanel.js'; import { LogPanel } from '../LogPanel.js'; import { render } from 'ink-testing-library'; import React from 'react'; +import stripAnsi from 'strip-ansi'; import { afterEach, describe, expect, it, vi } from 'vitest'; const UP_ARROW = '\x1B[A'; @@ -19,7 +20,7 @@ describe('LogPanel', () => { describe('empty state', () => { it('renders "No output yet" with no other content', () => { const { lastFrame } = render(); - expect(lastFrame()).toBe('No output yet'); + expect(stripAnsi(lastFrame()!)).toBe('No output yet'); }); }); diff --git a/src/cli/tui/components/__tests__/SecretInput.test.tsx b/src/cli/tui/components/__tests__/SecretInput.test.tsx index 3b326ea2a..cf00b0378 100644 --- a/src/cli/tui/components/__tests__/SecretInput.test.tsx +++ b/src/cli/tui/components/__tests__/SecretInput.test.tsx @@ -1,6 +1,7 @@ import { ApiKeySecretInput, SecretInput } from '../SecretInput.js'; import { render } from 'ink-testing-library'; import React from 'react'; +import stripAnsi from 'strip-ansi'; import { afterEach, describe, expect, it, vi } from 'vitest'; import { z } from 'zod'; @@ -34,7 +35,7 @@ describe('SecretInput', () => { ); - expect(lastFrame()).toContain('sk-...'); + expect(stripAnsi(lastFrame()!)).toContain('sk-...'); }); it('masks input with default * character', async () => {