Skip to content

Commit 6518290

Browse files
super3claude
andcommitted
Fix TTY tests for GitHub Actions environment
- Create new MdTail instance after setting TTY for cursor tests - Set TERM environment variable to ensure ANSI support detection - Fixes test failures in CI environment 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0919b06 commit 6518290

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

test/mdtail.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,20 @@ describe('MdTail - Core Functionality', () => {
272272
let consoleClearSpy;
273273
let stdoutWriteSpy;
274274
let originalIsTTY;
275+
let originalTerm;
275276

276277
beforeEach(() => {
277278
originalIsTTY = process.stdout.isTTY;
279+
originalTerm = process.env.TERM;
278280
process.stdout.isTTY = true;
281+
process.env.TERM = 'xterm'; // Ensure ANSI support
279282
consoleClearSpy = jest.spyOn(console, 'clear').mockImplementation();
280283
stdoutWriteSpy = jest.spyOn(process.stdout, 'write').mockImplementation();
281284
});
282285

283286
afterEach(() => {
284287
process.stdout.isTTY = originalIsTTY;
288+
process.env.TERM = originalTerm;
285289
consoleClearSpy.mockRestore();
286290
stdoutWriteSpy.mockRestore();
287291
});
@@ -292,12 +296,16 @@ describe('MdTail - Core Functionality', () => {
292296
});
293297

294298
test('should hide cursor', () => {
295-
mdtail.hideCursor();
299+
// Create a new instance after setting TTY
300+
const mdtailWithTTY = new MdTail();
301+
mdtailWithTTY.hideCursor();
296302
expect(stdoutWriteSpy).toHaveBeenCalledWith('\x1B[?25l');
297303
});
298304

299305
test('should show cursor', () => {
300-
mdtail.showCursor();
306+
// Create a new instance after setting TTY
307+
const mdtailWithTTY = new MdTail();
308+
mdtailWithTTY.showCursor();
301309
expect(stdoutWriteSpy).toHaveBeenCalledWith('\x1B[?25h');
302310
});
303311
});

0 commit comments

Comments
 (0)