-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move mock api pool to test setup
- Loading branch information
1 parent
2ac95d1
commit 6431388
Showing
7 changed files
with
28 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
import { afterEach, beforeEach, vi } from 'vitest'; | ||
import { setGlobalDispatcher } from 'undici'; | ||
import { afterAll, afterEach, beforeAll, beforeEach, vi } from 'vitest'; | ||
import { mockApiAgent } from './src/mocks/api'; | ||
|
||
beforeAll(() => { | ||
setGlobalDispatcher(mockApiAgent); | ||
}); | ||
|
||
beforeEach(() => { | ||
vi.useFakeTimers(); | ||
}); | ||
|
||
afterEach(() => { | ||
afterEach(async () => { | ||
vi.clearAllMocks(); | ||
vi.clearAllTimers(); | ||
vi.runAllTimers(); | ||
vi.useRealTimers(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await mockApiAgent.close(); | ||
}); |