refactor: improve test structure for Bun compatibility
- Update all test files to use named mock variables instead of inline mocks - Clear mock history in beforeEach instead of using mock.restore() - Add default mock implementations stored at module level - Document that tests should not use --randomize flag due to mock.module() limitations - All 89 unit tests pass consistently without randomization
This commit is contained in:
@@ -2,7 +2,7 @@ import { describe, it, expect, mock, beforeEach, MockedFunction } from 'bun:test
|
||||
import { getSession } from '@/lib/auth-simple'
|
||||
|
||||
// Mock next/headers
|
||||
vi.mock('next/headers', () => ({
|
||||
mock.module('next/headers', () => ({
|
||||
cookies: mock(() => {}).mockResolvedValue({
|
||||
get: mock(() => {}).mockReturnValue({ name: 'better-auth.session_token', value: 'test-token' }),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user