refactor(web): migrate to Vitest and esm (#29974)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
Stephen Zhou
2025-12-22 16:35:22 +08:00
committed by GitHub
parent 42f7ecda12
commit eabdc5f0eb
268 changed files with 5455 additions and 6307 deletions

View File

@ -2,13 +2,13 @@ import { render, screen } from '@testing-library/react'
import { TopBar, type TopBarProps } from './index'
// Mock next/link to capture href values
jest.mock('next/link', () => {
return ({ children, href, replace, className }: { children: React.ReactNode; href: string; replace?: boolean; className?: string }) => (
vi.mock('next/link', () => ({
default: ({ children, href, replace, className }: { children: React.ReactNode; href: string; replace?: boolean; className?: string }) => (
<a href={href} data-replace={replace} className={className} data-testid="back-link">
{children}
</a>
)
})
),
}))
// Helper to render TopBar with default props
const renderTopBar = (props: Partial<TopBarProps> = {}) => {
@ -27,7 +27,7 @@ const renderTopBar = (props: Partial<TopBarProps> = {}) => {
// ============================================================================
describe('TopBar', () => {
beforeEach(() => {
jest.clearAllMocks()
vi.clearAllMocks()
})
// --------------------------------------------------------------------------