From aebfe1af7f64602bd42b4cad5c23c72811e22d2e Mon Sep 17 00:00:00 2001 From: anshika1179 Date: Sun, 31 May 2026 02:16:31 +0530 Subject: [PATCH] fix: prevent Framer Motion props from reaching DOM elements --- app/components/FeatureCard.test.tsx | 17 +++++++-- app/page.test.tsx | 47 ++++++++++++++++++++++-- components/dashboard/AIInsights.test.tsx | 15 +++++++- components/dashboard/StatsCard.test.tsx | 15 +++++++- 4 files changed, 86 insertions(+), 8 deletions(-) diff --git a/app/components/FeatureCard.test.tsx b/app/components/FeatureCard.test.tsx index 707ac477..11f5747e 100644 --- a/app/components/FeatureCard.test.tsx +++ b/app/components/FeatureCard.test.tsx @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { describe, it, expect, vi } from 'vitest'; import { render, screen } from '@testing-library/react'; import { FeatureCard } from './FeatureCard'; @@ -6,9 +8,18 @@ import { FeatureCard } from './FeatureCard'; // don't mean anything to jsdom, so we stub motion.div with a plain div. vi.mock('framer-motion', () => ({ motion: { - div: ({ children, ...props }: React.HTMLAttributes) => ( -
{children}
- ), + div: ({ + children, + whileHover, + whileTap, + whileInView, + initial, + animate, + exit, + transition, + viewport, + ...props + }: any) =>
{children}
, }, })); diff --git a/app/page.test.tsx b/app/page.test.tsx index 4084d494..b5905efb 100644 --- a/app/page.test.tsx +++ b/app/page.test.tsx @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @next/next/no-img-element, jsx-a11y/alt-text */ import { render, screen, fireEvent, waitFor, act } from '@testing-library/react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; @@ -31,17 +32,57 @@ vi.mock('next/link', () => ({ // Mock framer-motion vi.mock('framer-motion', () => ({ motion: { - div: ({ children, className, ...props }: any) => ( + div: ({ + children, + className, + whileHover, + whileTap, + whileInView, + initial, + animate, + exit, + transition, + viewport, + layoutId, + ...props + }: any) => (
{children}
), - p: ({ children, className, ...props }: any) => ( + p: ({ + children, + className, + whileHover, + whileTap, + whileInView, + initial, + animate, + exit, + transition, + viewport, + layoutId, + ...props + }: any) => (

{children}

), - a: ({ children, className, href, ...props }: any) => ( + a: ({ + children, + className, + href, + whileHover, + whileTap, + whileInView, + initial, + animate, + exit, + transition, + viewport, + layoutId, + ...props + }: any) => ( {children} diff --git a/components/dashboard/AIInsights.test.tsx b/components/dashboard/AIInsights.test.tsx index b848a670..b3269f0f 100644 --- a/components/dashboard/AIInsights.test.tsx +++ b/components/dashboard/AIInsights.test.tsx @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { render, screen } from '@testing-library/react'; import AIInsights from './AIInsights'; @@ -7,7 +8,19 @@ import type { AIInsight } from '@/types/dashboard'; // Mock framer-motion vi.mock('framer-motion', () => ({ motion: { - div: ({ children, ...props }: any) => ( + div: ({ + children, + whileHover, + whileTap, + whileInView, + initial, + animate, + exit, + transition, + viewport, + layoutId, + ...props + }: any) => (
{children}
diff --git a/components/dashboard/StatsCard.test.tsx b/components/dashboard/StatsCard.test.tsx index c248f69e..3a56edf9 100644 --- a/components/dashboard/StatsCard.test.tsx +++ b/components/dashboard/StatsCard.test.tsx @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { describe, it, expect, vi, beforeEach } from 'vitest'; import { render, screen } from '@testing-library/react'; import StatsCard from './StatsCard'; @@ -6,7 +7,19 @@ import StatsCard from './StatsCard'; // Mock framer-motion vi.mock('framer-motion', () => ({ motion: { - div: ({ children, ...props }: any) => ( + div: ({ + children, + whileHover, + whileTap, + whileInView, + initial, + animate, + exit, + transition, + viewport, + layoutId, + ...props + }: any) => (
{children}