diff --git a/src/test-utils.ts b/src/test-utils.ts index 3acf9a20..c6caae44 100644 --- a/src/test-utils.ts +++ b/src/test-utils.ts @@ -93,6 +93,10 @@ export function resetIntersectionMocking() { observers.clear(); } +function getIsReactActEnvironment() { + return Boolean(global.IS_REACT_ACT_ENVIRONMENT); +} + function triggerIntersection( elements: Element[], trigger: boolean | number, @@ -148,7 +152,8 @@ function triggerIntersection( } // Trigger the IntersectionObserver callback with all the entries - if (act) act(() => item.callback(entries, observer)); + if (act && getIsReactActEnvironment()) + act(() => item.callback(entries, observer)); else item.callback(entries, observer); } /**