fix: improve TypeScript types for better IDE code hinting
- Install @types/bun and @types/jsdom for proper type definitions - Fix mock function typing in test files - Create jest-dom.d.ts to properly extend Bun's Matchers interface - Remove MockedFunction imports (not supported in Bun's types) - Cast global.fetch and useSession mocks to any where needed - Fix mock.module return types to match expected signatures This resolves TypeScript errors that were preventing proper code completion and type checking in IDEs.
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import { describe, it, expect, mock, beforeEach, MockedFunction } from 'bun:test'
|
||||
import { describe, it, expect, mock, beforeEach } from 'bun:test'
|
||||
import { getSession } from '@/lib/auth-simple'
|
||||
|
||||
// Mock next/headers
|
||||
mock.module('next/headers', () => ({
|
||||
cookies: mock(() => {}).mockResolvedValue({
|
||||
get: mock(() => {}).mockReturnValue({ name: 'better-auth.session_token', value: 'test-token' }),
|
||||
}),
|
||||
headers: mock(() => {}).mockResolvedValue({
|
||||
get: mock(() => {}).mockReturnValue(null),
|
||||
}),
|
||||
cookies: mock(() => Promise.resolve({
|
||||
get: mock(() => ({ name: 'better-auth.session_token', value: 'test-token' })),
|
||||
})),
|
||||
headers: mock(() => Promise.resolve({
|
||||
get: mock(() => null),
|
||||
})),
|
||||
}))
|
||||
|
||||
// Mock fetch
|
||||
const mockFetch = mock(() => {})
|
||||
global.fetch = mockFetch as MockedFunction<typeof global.fetch>
|
||||
const mockFetch = mock(async () => new Response())
|
||||
global.fetch = mockFetch as any
|
||||
|
||||
describe('getSession', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user