Skip to content

test: fix Vitest JSX compilation and mock window.matchMedia#1389

Open
Abhishek2005-ard wants to merge 8 commits into
magic-peach:mainfrom
Abhishek2005-ard:fix/vitest-jsx-compilation
Open

test: fix Vitest JSX compilation and mock window.matchMedia#1389
Abhishek2005-ard wants to merge 8 commits into
magic-peach:mainfrom
Abhishek2005-ard:fix/vitest-jsx-compilation

Conversation

@Abhishek2005-ard
Copy link
Copy Markdown

Description

This PR resolves an issue where the test suite was immediately failing with a vite:import-analysis error when executing component tests.

Since the project delegates JSX transpilation to Next.js ("jsx": "preserve" in tsconfig.json), Vitest required a plugin to understand React .tsx syntax. Additionally, the JSDOM test environment does not natively support window.matchMedia, which caused the ThemeToggle.test.tsx test to fail once compilation succeeded.

Changes Made

  • Dependencies: Installed @vitejs/plugin-react as a dev dependency to handle JSX compilation.
  • Vitest Config: Updated vitest.config.ts to include the React Vite plugin.
  • Vitest Setup: Added a global mock for window.matchMedia inside vitest.setup.ts to ensure components that utilize media queries (like the theme logic) can be tested properly in JSDOM.

Testing Instructions

  1. Run npm run test or npx vitest.
  2. Verify that the test suite compiles successfully and all 71 tests execute and pass without throwing syntax errors or TypeError: window.matchMedia is not a function.

close #1385

@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

@Abhishek2005-ard is attempting to deploy a commit to the magic-peach1's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @Abhishek2005-ard!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

✅ PR Format Check Passed — @Abhishek2005-ard

Basic format checks passed. A maintainer will review your code changes.

This does not mean the PR is approved — it just means the format is correct.

@github-actions github-actions Bot added level:advanced Advanced level - 55 pts type:bug Bug fix type:testing Testing labels May 29, 2026
@Abhishek2005-ard
Copy link
Copy Markdown
Author

@magic-peach
pls review this pr when you have time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:advanced Advanced level - 55 pts type:bug Bug fix type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Vitest fails to parse JSX/TSX files due to missing React Vite plugin

1 participant