Skip to content

Commit b4a6c72

Browse files
committed
fix(test): also clear spy history in afterEach teardown
Add mockClear() calls in teardownStdioTest before mockRestore() to ensure spy call history is cleaned up both before and after each test. This provides more robust test isolation for Node.js 24 where spy state may persist across test boundaries.
1 parent 19bab41 commit b4a6c72

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/utils/stdio-test-helper.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export function teardownStdioTest(
6666
stream: NodeJS.WriteStream & Writable,
6767
context: StdioTestContext,
6868
): void {
69+
// Clear call history before restoring
70+
context.writeSpy?.mockClear()
71+
context.cursorToSpy?.mockClear()
72+
context.clearLineSpy?.mockClear()
73+
context.clearScreenDownSpy?.mockClear()
74+
6975
// Restore spies
7076
context.writeSpy?.mockRestore()
7177
context.cursorToSpy?.mockRestore()

0 commit comments

Comments
 (0)