File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,6 +72,19 @@ function withGlobalActEnvironment(actImplementation) {
7272 return actResult
7373 }
7474 } catch ( error ) {
75+ // https://github.com/testing-library/react-testing-library/issues/1392
76+ // https://github.com/testing-library/react-testing-library/issues/1399
77+ if (
78+ Error . isError ( error ) &&
79+ error . toString ( ) === 'TypeError: React.act is not a function' &&
80+ process &&
81+ process . env . NODE_ENV === 'production'
82+ ) {
83+ throw new Error (
84+ 'Following error may be caused by `NODE_ENV` environment variable being set to `production`. Try changing it to `test`.' ,
85+ { cause : error } ,
86+ )
87+ }
7588 // Can't be a `finally {}` block since we don't know if we have to immediately restore IS_REACT_ACT_ENVIRONMENT
7689 // or if we have to await the callback first.
7790 setIsReactActEnvironment ( previousActEnvironment )
You can’t perform that action at this time.
0 commit comments