{"record":{"id":"54a499b246f2f52d","repo":"facebook/react","slug":"act-is-not-supported-in-production-builds-of","errorCode":null,"errorMessage":"act(...) is not supported in production builds of React.","messagePattern":"act\\(\\.\\.\\.\\) is not supported in production builds of React\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react/src/ReactAct.js","lineNumber":252,"sourceCode":"      return {\n        then(resolve: T => mixed, reject: mixed => mixed) {\n          didAwaitActCall = true;\n          if (prevActScopeDepth === 0) {\n            // If the `act` call is awaited, restore the queue we were\n            // using before (see long comment above) so we can flush it.\n            ReactSharedInternals.actQueue = queue;\n            queueMacrotask(() =>\n              // Recursively flush tasks scheduled by a microtask.\n              recursivelyFlushAsyncActWork(returnValue, resolve, reject),\n            );\n          } else {\n            resolve(returnValue);\n          }\n        },\n      };\n    }\n  } else {\n    throw new Error('act(...) is not supported in production builds of React.');\n  }\n}\n\nfunction popActScope(\n  prevActQueue: null | Array<RendererTask>,\n  prevActScopeDepth: number,\n) {\n  if (__DEV__) {\n    if (prevActScopeDepth !== actScopeDepth - 1) {\n      console.error(\n        'You seem to have overlapping act() calls, this is not supported. ' +\n          'Be sure to await previous act() calls before making a new one. ',\n      );\n    }\n    actScopeDepth = prevActScopeDepth;\n  }\n}\n","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react/src/ReactAct.js#L234-L270","documentation":"React's act() testing helper only ships in development builds; the production/minified channel replaces it with a stub that throws immediately when called. React intentionally disables act() in production because IS_REACT_ACT_ENVIRONMENT and the act queue only exist in DEV.","triggerScenarios":"Calling act(...) while the resolved 'react' module is a production build — e.g. NODE_ENV=production during tests, or a test importing an app bundle built in production mode.","commonSituations":"Jest config or CI setting NODE_ENV=production; tests that import a prebuilt/minified bundle (dist file) instead of source; Vite/Webpack test setups aliasing react to its .production.min entry.","solutions":["Run tests with NODE_ENV=test (Jest sets this by default) or development","Make the test setup resolve 'react'/'react-dom' to the development CJS builds (e.g. jest.moduleDirectories, or remove aliases to *.production.min.js)","If testing a built bundle, build it in development mode for the test pass"],"exampleFix":"// before (jest.config.js)\nmodule.exports = { testEnvironment: 'node' }; // run with NODE_ENV=production -> act throws\n\n// after\n// package.json\n\"scripts\": { \"test\": \"cross-env NODE_ENV=test jest\" }\n// or ensure no resolver alias like:\n// react -> react/cjs/react.production.min.js","handlingStrategy":"validation","validationCode":"// Skip act-dependent logic in production builds\nconst isDevAct = typeof IS_REACT_ACT_ENVIRONMENT !== 'undefined' || process.env.NODE_ENV !== 'production';\nif (isDevAct) {\n  await act(async () => { renderSomething(); });\n} else {\n  renderSomething(); // no act in production bundles\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run jest/vitest with NODE_ENV=test (the default) and never override it to production in test scripts","Do not import prebuilt production bundles of react/react-dom into tests; resolve the dev builds","Set globalThis.IS_REACT_ACT_ENVIRONMENT = true in the test setup for React 18+"],"tags":["testing","act","production-build","node-env","jest"],"backgroundTag":"act-in-production-build","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}