setupTests.ts•853 B
/**
* Global test setup file for Jest
* This file runs before all tests to set up the testing environment
*/
import { beforeAll, beforeEach, afterAll, jest } from '@jest/globals';
import { cacheService } from '../utils/cache';
// Load our database mocks
import './mocks/db.mock';
// Set test environment variables if needed
process.env.NODE_ENV = 'test';
// Global setup - runs once before all tests
beforeAll(async () => {
// Database connection is mocked, no real connection needed
// Initialization code if needed can go here
});
// Run before each test
beforeEach(() => {
// Clear cache before each test to ensure isolation
cacheService.clear();
// Reset mock implementations if needed
jest.clearAllMocks();
});
// Global teardown - runs once after all tests
afterAll(async () => {
// Cleanup code if needed can go here
});