Skip to content

Commit 03a5e05

Browse files
committed
fix(test): clear spy mock calls after beforeEach setup
Added mockClear() calls after creating spies in beforeEach to prevent setup calls from interfering with test assertions. This fixes test failures on Windows CI where mock call counts were higher than expected. Affected tests: - test/stdio/stderr.test.ts (4 tests) - test/stdio/stdout.test.ts (preventive fix) Fixes mock call count assertions to only count calls made during the actual test, not during beforeEach setup.
1 parent 9f37123 commit 03a5e05

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

test/stdio/stderr.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ describe('stdio/stderr', () => {
4747
cursorToSpy = vi.spyOn(stderr, 'cursorTo').mockImplementation(() => {})
4848
// @ts-expect-error - Vitest spy type doesn't match ReturnType<typeof vi.spyOn>
4949
clearLineSpy = vi.spyOn(stderr, 'clearLine').mockImplementation(() => {})
50+
51+
// Clear any calls made during setup
52+
writeSpy.mockClear()
53+
cursorToSpy.mockClear()
54+
clearLineSpy.mockClear()
5055
})
5156

5257
afterEach(() => {

test/stdio/stdout.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ describe('stdio/stdout', () => {
6262
.spyOn(stdout, 'clearScreenDown')
6363
// @ts-expect-error - Vitest mock type doesn't match expected implementation signature
6464
.mockImplementation(() => {})
65+
66+
// Clear any calls made during setup
67+
writeSpy.mockClear()
68+
cursorToSpy.mockClear()
69+
clearLineSpy.mockClear()
70+
clearScreenDownSpy.mockClear()
6571
})
6672

6773
afterEach(() => {

0 commit comments

Comments
 (0)