From 23cb3316574864308c32099459d62a4ee63471cc Mon Sep 17 00:00:00 2001 From: Keith Guerin Date: Sun, 1 Mar 2026 12:48:43 -0800 Subject: [PATCH] fix(cli): make string-width test environment-agnostic --- packages/cli/src/ui/utils/textUtils.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/ui/utils/textUtils.test.ts b/packages/cli/src/ui/utils/textUtils.test.ts index 4927486d43..7fdc72c2d7 100644 --- a/packages/cli/src/ui/utils/textUtils.test.ts +++ b/packages/cli/src/ui/utils/textUtils.test.ts @@ -48,12 +48,13 @@ describe('textUtils', () => { it('should handle unicode characters that crash string-width', () => { // U+0602 caused string-width to crash (see #16418) const char = '؂'; - expect(getCachedStringWidth(char)).toBe(1); + // Some environments return 0, others 1. The key is that it doesn't crash. + expect([0, 1]).toContain(getCachedStringWidth(char)); }); it('should handle unicode characters that crash string-width with ANSI codes', () => { const charWithAnsi = '\u001b[31m' + '؂' + '\u001b[0m'; - expect(getCachedStringWidth(charWithAnsi)).toBe(1); + expect([0, 1]).toContain(getCachedStringWidth(charWithAnsi)); }); });