Skip to content

Fix React.act infrastructure issue in jsdom component tests (React 19 + @testing-library/react) #320

@brendanlong

Description

@brendanlong

Problem

All component tests (run via pnpm test:component / vitest.component.config.ts) are currently failing with:

TypeError: React.act is not a function

This affects src/components/**/*.test.tsx, src/lib/**/*.test.tsx, and any React hook tests in src/hooks/**/*.test.ts.

Root Cause

React 19 moved act to the react package directly, away from react-dom/test-utils. The @testing-library/react@16.3.2 tries to use React.act via react-dom/test-utils, which loads the production bundle of React where act is not exported.

Impact

  • All 92 component tests are failing
  • Hook tests that use renderHook from @testing-library/react also fail
  • src/hooks/useVoiceRecording.test.ts is currently marked .skip due to this issue

Possible Fixes

  1. Upgrade @testing-library/react to a version that fully supports React 19
  2. Configure vitest to always use React's development bundle in test environments
  3. Add @testing-library/react React 19 compatibility configuration

— Claude

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions