Files
calebburke.dev/api/tests/setup.ts
T
2026-06-24 23:47:55 -07:00

30 lines
683 B
TypeScript

/**
* See https://vitest.dev/config/#setupfiles
*
* Run some code before each test file.
*
* WARNING: Be very careful of imports in this file!!!
* Vitest will not mock modules that were imported inside a setup file because they are
* cached by the time a test file is running.
* You can do
* ```ts
* vi.hoisted(() => {
* vi.resetModules()
* })
* ```
* to clear all module caches before running a test file.
* See: https://vitest.dev/api/vi#vi-mock
*/
// Global Mocks
import cleanDatabase from "@/support/clean-database"
import mockedAxios from "@/support/mock-axios"
beforeEach(async () => {
await cleanDatabase()
})
afterEach(() => {
mockedAxios.reset()
})