Skip to content

Commit bdd0408

Browse files
Fix missing timer cleanup in TTS route tests
Add afterEach to useRealTimers to prevent timer leak between tests in getCachedAudio describe block
1 parent 8233fec commit bdd0408

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

backend/test/routes/tts.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, vi, beforeEach } from 'vitest'
1+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
22
import * as fs from 'fs/promises'
33

44
vi.mock('fs/promises', () => ({
@@ -78,9 +78,13 @@ describe('TTS Routes', () => {
7878
})
7979

8080
describe('getCachedAudio', () => {
81-
beforeEach(() => {
82-
vi.useFakeTimers()
83-
})
81+
beforeEach(() => {
82+
vi.useFakeTimers()
83+
})
84+
85+
afterEach(() => {
86+
vi.useRealTimers()
87+
})
8488

8589
it('should return cached audio when file exists and is not expired', async () => {
8690
const cacheKey = 'test-key'

0 commit comments

Comments
 (0)