test: mock react-syntax-highlighter to fix ESM compatibility in CodeBlock tests

This commit is contained in:
Ajax Davis 2025-12-04 20:06:41 +10:00
parent 5c2cc529ef
commit 0a37ca5aa7

View file

@ -2,6 +2,16 @@ import { render, screen, waitFor } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { CodeBlock } from './CodeBlock';
// Mock react-syntax-highlighter to avoid ESM compatibility issues
vi.mock('react-syntax-highlighter', () => ({
Prism: ({ children, ...props }: any) => <code {...props}>{children}</code>,
}));
vi.mock('react-syntax-highlighter/dist/esm/styles/prism', () => ({
prism: {},
vscDarkPlus: {},
}));
// Mock clipboard API
const mockClipboard = {
writeText: vi.fn(),