fix(web): add Next.js module mocks for Vitest — all 14 tests pass (was 10/14)
This commit is contained in:
parent
e716ca1ef6
commit
82ede5a107
5
web/src/test/__mocks__/next-link.tsx
Normal file
5
web/src/test/__mocks__/next-link.tsx
Normal 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>;
|
||||||
|
}
|
||||||
13
web/src/test/__mocks__/next-navigation.ts
Normal file
13
web/src/test/__mocks__/next-navigation.ts
Normal 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 = () => {};
|
||||||
@ -11,6 +11,8 @@ export default defineConfig({
|
|||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": path.resolve(__dirname, "./src"),
|
"@": 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"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user