feat: add unit tests and CI configuration

This commit is contained in:
Usman Baig
2026-03-01 00:11:54 +01:00
parent bce56fa64d
commit b5f83ce582
12 changed files with 2798 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
describe('logger', () => {
beforeEach(() => {
vi.resetModules()
})
it('calls console.error in development', async () => {
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
process.env.NODE_ENV = 'development'
const { logger } = await import('../logger')
logger.error('test error')
expect(spy).toHaveBeenCalledWith('test error')
spy.mockRestore()
})
it('calls console.warn in development', async () => {
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {})
process.env.NODE_ENV = 'development'
const { logger } = await import('../logger')
logger.warn('test warning')
expect(spy).toHaveBeenCalledWith('test warning')
spy.mockRestore()
})
})