hrms-checkin/tests/utils.ts

26 lines
574 B
TypeScript

import { enableAutoUnmount, flushPromises, VueWrapper } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
/**
* Helper function to setup test environment with Pinia
*/
export function setupTest() {
const pinia = createPinia()
setActivePinia(pinia)
return pinia
}
/**
* Helper to flush all pending promises
*/
export async function flushAllPromises() {
await flushPromises()
await new Promise((resolve) => setTimeout(resolve, 0))
}
/**
* Helper to cleanup after each test
*/
export function teardownTest() {
vi.clearAllMocks()
}