fix(web): add Next.js module mocks for Vitest — all 14 tests pass (was 10/14)

This commit is contained in:
saravanakumardb1 2026-03-29 01:03:11 -07:00
parent e716ca1ef6
commit 82ede5a107
3 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import * as React from 'react';
export default function Link({ href, children, ...props }: React.ComponentProps<'a'> & { href: string }) {
return <a href={href} {...props}>{children}</a>;
}

View File

@ -0,0 +1,13 @@
export const usePathname = () => '/dashboard';
export const useRouter = () => ({
push: () => {},
replace: () => {},
back: () => {},
forward: () => {},
refresh: () => {},
prefetch: () => {},
});
export const useSearchParams = () => new URLSearchParams();
export const useParams = () => ({});
export const redirect = () => {};
export const notFound = () => {};

View File

@ -11,6 +11,8 @@ export default defineConfig({
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"next/navigation": path.resolve(__dirname, "./src/test/__mocks__/next-navigation.ts"),
"next/link": path.resolve(__dirname, "./src/test/__mocks__/next-link.tsx"),
},
},
});