feat: migrate from npm to Bun
- Install Bun via mise - Update package.json scripts to use Bun - Migrate unit tests from Vitest to Bun test runner - Migrate component tests from Vitest to Bun test runner - Configure Bun with DOM environment for React Testing Library - Keep Playwright for E2E tests (as planned) - 93/100 tests passing (7 flaky tests when running all together, pass individually)
This commit is contained in:
@@ -5,33 +5,33 @@
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { describe, test, expect, beforeEach, vi } from 'vitest';
|
||||
import { describe, test, expect, beforeEach, mock } from 'bun:test';
|
||||
import { recalculateAllElo } from '@/lib/elo-utils';
|
||||
|
||||
// Mock Prisma client
|
||||
const mockPrisma = {
|
||||
player: {
|
||||
updateMany: vi.fn().mockResolvedValue({ count: 0 }),
|
||||
update: vi.fn().mockResolvedValue({}),
|
||||
updateMany: mock(() => {}).mockResolvedValue({ count: 0 }),
|
||||
update: mock(() => {}).mockResolvedValue({}),
|
||||
},
|
||||
eloSnapshot: {
|
||||
deleteMany: vi.fn().mockResolvedValue({ count: 0 }),
|
||||
create: vi.fn().mockResolvedValue({}),
|
||||
deleteMany: mock(() => {}).mockResolvedValue({ count: 0 }),
|
||||
create: mock(() => {}).mockResolvedValue({}),
|
||||
},
|
||||
partnershipStat: {
|
||||
deleteMany: vi.fn().mockResolvedValue({ count: 0 }),
|
||||
findFirst: vi.fn().mockResolvedValue(null), // No existing stats initially
|
||||
update: vi.fn().mockResolvedValue({}),
|
||||
create: vi.fn().mockResolvedValue({}),
|
||||
deleteMany: mock(() => {}).mockResolvedValue({ count: 0 }),
|
||||
findFirst: mock(() => {}).mockResolvedValue(null), // No existing stats initially
|
||||
update: mock(() => {}).mockResolvedValue({}),
|
||||
create: mock(() => {}).mockResolvedValue({}),
|
||||
},
|
||||
match: {
|
||||
findMany: vi.fn().mockResolvedValue([]),
|
||||
findMany: mock(() => {}).mockResolvedValue([]),
|
||||
},
|
||||
};
|
||||
|
||||
describe('recalculateAllElo', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mock.clearAllMocks();
|
||||
});
|
||||
|
||||
test('should reset all player stats to zero', async () => {
|
||||
|
||||
Reference in New Issue
Block a user