testing-library/react-testing-library

React.act is not a function

Closed this issue · 1 comments

When NODE_ENV is set to production tests will fail with the following error:

TypeError: React.act is not a function
 ❯ exports.act ../../node_modules/.pnpm/react-dom@19.1.0_react@19.1.0/node_modules/react-dom/cjs/react-dom-test-utils.production.js:20:16
 ❯ ../../node_modules/.pnpm/@testing-library+react@16.3.0_@testing-library+dom@10.4.0_@types+react-dom@19.1.3_@type_663406122d5b9765f6653a6e4ab277b1/node_modules/@testing-library/react/dist/act-compat.js:47:25

Same issue: #1392

  • "vitest": "3.1.2"
  • "@testing-library/dom": "10.4.0",
  • "@testing-library/react": "16.3.0",
  • "react": "19.1.0",
  • "react-dom": "19.1.0",

Thanks for opening this one.. Why do you have NODE_ENV set to production? This is only useful for e2e environments where act isn't really needed AFAIK.
I'm closing this one since either way - act isn't exported in production mode and this is a React definition not a Testing-Library decision.