Skip to content

Commit a9adcac

Browse files
committed
fix(test): add TTY method stubs for non-TTY environments in stdio tests
- Add stub methods (cursorTo, clearLine, clearScreenDown) before spying - Prevents 'property is not defined' errors when stdout/stderr are not TTYs - Enables tests to run in CI and non-terminal environments
1 parent 41ef3be commit a9adcac

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

test/stdio/stderr.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ describe('stdio/stderr', () => {
3232
originalColumns = stderr.columns
3333
originalRows = stderr.rows
3434

35+
// Add TTY methods if they don't exist (for non-TTY environments)
36+
if (!stderr.cursorTo) {
37+
;(stderr as any).cursorTo = () => {}
38+
}
39+
if (!stderr.clearLine) {
40+
;(stderr as any).clearLine = () => {}
41+
}
42+
3543
// Create spies
3644
writeSpy = vi.spyOn(stderr, 'write').mockImplementation(() => true)
3745
cursorToSpy = vi.spyOn(stderr, 'cursorTo').mockImplementation(() => {})

test/stdio/stdout.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ describe('stdio/stdout', () => {
3636
originalColumns = stdout.columns
3737
originalRows = stdout.rows
3838

39+
// Add TTY methods if they don't exist (for non-TTY environments)
40+
if (!stdout.cursorTo) {
41+
;(stdout as any).cursorTo = () => {}
42+
}
43+
if (!stdout.clearLine) {
44+
;(stdout as any).clearLine = () => {}
45+
}
46+
if (!stdout.clearScreenDown) {
47+
;(stdout as any).clearScreenDown = () => {}
48+
}
49+
3950
// Create spies
4051
writeSpy = vi.spyOn(stdout, 'write').mockImplementation(() => true)
4152
cursorToSpy = vi.spyOn(stdout, 'cursorTo').mockImplementation(() => {})

0 commit comments

Comments
 (0)