Skip to content

Commit 024d687

Browse files
committed
fix: ensure error-path tests set non-interactive mode before spying
Tests that spy on console.log for error output must first establish non-interactive mode, otherwise the assertion depends on host TTY state.
1 parent 1ff720a commit 024d687

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

tests/commands/auth/login.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
captureTestEnv,
2121
expectExit1,
2222
mockExitThrow,
23+
setNonInteractive,
2324
setupOutputSpies,
2425
} from '../../helpers';
2526

@@ -75,6 +76,7 @@ describe('login command', () => {
7576
},
7677
};
7778

79+
setNonInteractive();
7880
errorSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
7981
exitSpy = mockExitThrow();
8082

@@ -94,6 +96,7 @@ describe('login command', () => {
9496
});
9597

9698
test('rejects key not starting with re_', async () => {
99+
setNonInteractive();
97100
errorSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
98101
exitSpy = mockExitThrow();
99102

tests/commands/auth/logout.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ describe('logout command', () => {
134134
});
135135

136136
test('exits with error when file removal fails', async () => {
137+
spies = setupOutputSpies();
137138
errorSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
138139
exitSpy = mockExitThrow();
139-
spies = setupOutputSpies();
140140
writeCredentials();
141141

142142
// Make the credentials file a directory so unlinkSync throws

0 commit comments

Comments
 (0)