73 lines
No EOL
1.6 KiB
TypeScript
73 lines
No EOL
1.6 KiB
TypeScript
/**
|
|
* Vitest setup file for fixtures tests
|
|
*/
|
|
|
|
import { beforeAll, afterAll, beforeEach, afterEach } from 'vitest'
|
|
import { loadConfig, setGlobalConfig } from '../core/config'
|
|
import { DataRelationManager } from '../core/utils/data-relations'
|
|
|
|
// Global test configuration
|
|
beforeAll(async () => {
|
|
// Set up test environment
|
|
const config = loadConfig('testing')
|
|
setGlobalConfig(config)
|
|
|
|
console.log('🧪 Test environment initialized')
|
|
})
|
|
|
|
afterAll(async () => {
|
|
// Global cleanup
|
|
DataRelationManager.clearAll()
|
|
console.log('🧹 Test environment cleaned up')
|
|
})
|
|
|
|
beforeEach(() => {
|
|
// Clear data before each test to ensure isolation
|
|
DataRelationManager.clearAll()
|
|
})
|
|
|
|
afterEach(() => {
|
|
// Optional: Clean up after each test
|
|
// DataRelationManager.clearAll()
|
|
})
|
|
|
|
// Mock console methods for cleaner test output
|
|
const originalLog = console.log
|
|
const originalWarn = console.warn
|
|
const originalError = console.error
|
|
|
|
// Only show errors in tests unless explicitly testing logging
|
|
console.log = () => {}
|
|
console.warn = () => {}
|
|
console.error = originalError
|
|
|
|
// Restore console methods if needed for debugging
|
|
export const restoreConsole = () => {
|
|
console.log = originalLog
|
|
console.warn = originalWarn
|
|
console.error = originalError
|
|
}
|
|
|
|
// Test utilities
|
|
export const testConfig = {
|
|
users: {
|
|
count: 10,
|
|
adminCount: 1,
|
|
artistCount: 2,
|
|
producerCount: 1,
|
|
},
|
|
audio: {
|
|
trackCount: 20,
|
|
albumCount: 3,
|
|
playlistCount: 5,
|
|
},
|
|
conversations: {
|
|
directCount: 5,
|
|
groupCount: 2,
|
|
channelCount: 1,
|
|
}
|
|
}
|
|
|
|
export const generateTestData = () => {
|
|
return DataRelationManager.generateCompleteDataset()
|
|
} |