dillon1000/react
Commit
Browse files Replace global `jest` heuristic with `IS_REACT_ACT_ENVIRONMENT` (#22562)
* Remove `jest` global check in concurrent roots In concurrent mode, instead of checking `jest`, we check the new `IS_REACT_ACT_ENVIRONMENT` global. The default behavior is `false`. Legacy mode behavior is unchanged. React's own internal test suite use a custom version of `act` that works by mocking the Scheduler — rather than the "real" act used publicly. So we don't enable the flag in our repo. * Warn if `act` is called in wrong environment Adds a warning if `act` is called but `IS_REACT_ACT_ENVIRONMENT` is not enabled. The goal is to prompt users to correctly configure their testing environment, so that if they forget to use `act` in a different test, we can detect and warn about. It's expected that the environment flag will be configured by the testing framework. For example, a Jest plugin. We will link to the relevant documentation page, once it exists. The warning only fires in concurrent mode. Legacy roots will keep the existing behavior.
Changed paths9 files
First-parent comparisonpackages/react-devtools-scheduling-profiler/src/import-worker/__tests__/preprocessData-test.internal.js ModifiedM packages/react-devtools-shared/src/__tests__/inspectedElement-test.js ModifiedM packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js ModifiedM packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js ModifiedM packages/react-reconciler/src/ReactFiberAct.new.js ModifiedM packages/react-reconciler/src/ReactFiberAct.old.js ModifiedM packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js ModifiedA packages/react-reconciler/src/__tests__/ReactActWarnings-test.js AddedM packages/react-reconciler/src/__tests__/SchedulingProfilerLabels-test.internal.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…