facebook/react · error · Error
react-dom/unstable_testing is not supported in React Server
Error message
react-dom/unstable_testing is not supported in React Server Components.
What it means
react-dom/unstable_testing exposes internal act() test-support hooks for the DOM client renderer. Under the react-server condition it resolves to a throwing stub, because those hooks mutate client-renderer internals that do not exist in a Server Components bundle. The error surfaces at import time in any test file compiled with the RSC condition.
Source
Thrown at packages/react-dom/npm/unstable_testing.react-server.js:3
'use strict'; throw new Error( 'react-dom/unstable_testing is not supported in React Server Components.' );
View on GitHub (pinned to eafeac097b)
Solutions
- Split test helpers into client and server variants and import react-dom/unstable_testing only in client tests
- Scope the react-server bundler condition to the directories that actually contain server-component code
- Use the act() re-exported by your testing library (e.g. @testing-library/react) instead of reaching into unstable_testing
- Dynamic-import unstable_testing only when a DOM document exists
Example fix
// before (test-utils.js shared by all tests)
import {act} from 'react-dom/unstable_testing';
// after (test-utils.client.js — imported only by client tests)
import {act} from 'react-dom/unstable_testing';
export {act}; Defensive patterns
Strategy: try-catch
Validate before calling
// test-support hooks are DOM-only
const needsDom = typeof window !== 'undefined' && typeof document !== 'undefined';
if (needsDom) {
const {act} = await import('react-dom/unstable_testing');
} Try / catch
let actImpl: typeof import('react-dom/unstable_testing').act | null = null;
try {
({act: actImpl} = await import('react-dom/unstable_testing'));
} catch {
actImpl = null; // RSC-compiled test bundle — use non-DOM assertions instead
} Prevention
- Split test-utils into client and server variants with separate import graphs
- Prefer the act() export from @testing-library/react over the internal unstable_testing path
- Configure Jest projects so server-component tests and DOM tests resolve different conditions
When it happens
Trigger: import {act} from 'react-dom/unstable_testing' in a test file that the bundler or Jest config compiles with the react-server condition, or a shared test-utils module (custom act wrapper) imported by both client and server-component tests.
Common situations: A test-utils helper imported from server-component tests; Jest moduleNameMapper or transform config applying react-server conditions globally; upgrading test helpers to support RSC test suites.
Related errors
- react-dom/profiling is not supported in React Server Compone
- react-dom/server is not supported in React Server Components
- react-dom/static is not supported in React Server Components
- The React Server cannot be used outside a react-server envir
- Use react-server-dom-turbopack/client instead.
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/adf4faa2a74e0550.
Report an issue: GitHub.