{"record":{"id":"adf4faa2a74e0550","repo":"facebook/react","slug":"react-dom-unstable-testing-is-not-supported-in-rea","errorCode":null,"errorMessage":"react-dom/unstable_testing is not supported in React Server Components.","messagePattern":"react-dom/unstable_testing is not supported in React Server Components\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-dom/npm/unstable_testing.react-server.js","lineNumber":3,"sourceCode":"'use strict';\n\nthrow new Error(\n  'react-dom/unstable_testing is not supported in React Server Components.'\n);\n","sourceCodeStart":1,"sourceCodeEnd":6,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-dom/npm/unstable_testing.react-server.js#L1-L6","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (test-utils.js shared by all tests)\nimport {act} from 'react-dom/unstable_testing';\n\n// after (test-utils.client.js — imported only by client tests)\nimport {act} from 'react-dom/unstable_testing';\nexport {act};","handlingStrategy":"try-catch","validationCode":"// test-support hooks are DOM-only\nconst needsDom = typeof window !== 'undefined' && typeof document !== 'undefined';\nif (needsDom) {\n  const {act} = await import('react-dom/unstable_testing');\n}","typeGuard":null,"tryCatchPattern":"let actImpl: typeof import('react-dom/unstable_testing').act | null = null;\ntry {\n  ({act: actImpl} = await import('react-dom/unstable_testing'));\n} catch {\n  actImpl = null; // RSC-compiled test bundle — use non-DOM assertions instead\n}","preventionTips":["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"],"tags":["react-server-components","react-dom","testing","act","import-time-error"],"backgroundTag":"unsupported-import-in-rsc","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}