feat: add Vitest and Playwright testing frameworks

Set up Vitest for unit/integration tests and Playwright for E2E tests; add configs, tests, and documentation

Co-authored-by: Moheeb Zara <[email protected]>
This commit is contained in:
v0
2026-03-11 07:54:17 +00:00
co-authored by Moheeb Zara
parent ef36527131
commit 3924534858
11 changed files with 2654 additions and 10 deletions
+46
View File
@@ -0,0 +1,46 @@
import '@testing-library/jest-dom'
import { expect, afterEach, vi } from 'vitest'
import { cleanup } from '@testing-library/react'
// Cleanup after each test
afterEach(() => {
cleanup()
})
// Mock next/navigation
vi.mock('next/navigation', () => ({
useRouter: () => ({
push: vi.fn(),
replace: vi.fn(),
prefetch: vi.fn(),
back: vi.fn(),
}),
usePathname: () => '/dashboard',
useSearchParams: () => new URLSearchParams(),
}))
// Mock next/image
vi.mock('next/image', () => ({
default: (props: any) => {
// eslint-disable-next-line jsx-a11y/alt-text
return <img {...props} />
},
}))
// Suppress console errors in tests (optional)
const originalError = console.error
beforeAll(() => {
console.error = (...args: any[]) => {
if (
typeof args[0] === 'string' &&
args[0].includes('Warning: ReactDOM.render')
) {
return
}
originalError.call(console, ...args)
}
})
afterAll(() => {
console.error = originalError
})