Fix TypeScript errors in test files

- Fixed vitest matcher usage: replaced toBeTypeOf with typeof + toBe
- Fixed import statements for fs and path modules to use namespace imports
- Resolves TypeScript compilation errors preventing push

Part of fixing test setup issues for PR #227
This commit is contained in:
Roo Code 2025-07-08 12:34:55 +00:00
parent 19b6fa3624
commit 96a1fc0a49
2 changed files with 8 additions and 6 deletions

View file

@ -1,7 +1,7 @@
// pnpm test src/app/api/events/backfill/__tests__/route.test.ts
import fs from 'fs';
import path from 'path';
import * as fs from 'fs';
import * as path from 'path';
import { NextRequest } from 'next/server';
import { authorizeApi } from '@/actions/auth';
@ -296,8 +296,8 @@ describe('/api/events/backfill', () => {
say: 'api_req_started',
});
expect(textMessage?.timestamp).toBeTypeOf('number');
expect(apiMessage?.timestamp).toBeTypeOf('number');
expect(typeof textMessage?.timestamp).toBe('number');
expect(typeof apiMessage?.timestamp).toBe('number');
const messageTypes = dbData.map((item) => item.say);
expect(messageTypes).toContain('text');

View file

@ -1,12 +1,14 @@
import '@testing-library/jest-dom';
(global as any).ResizeObserver = vi.fn().mockImplementation(() => ({
// Mock ResizeObserver
globalThis.ResizeObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}));
(global as any).IntersectionObserver = vi.fn().mockImplementation(() => ({
// Mock IntersectionObserver
globalThis.IntersectionObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),