diff --git a/scripts/fiber/tests-passing.txt b/scripts/fiber/tests-passing.txt index 78ed9f2cdf4c..3771b9694411 100644 --- a/scripts/fiber/tests-passing.txt +++ b/scripts/fiber/tests-passing.txt @@ -537,6 +537,7 @@ src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js * findDOMNode should find dom element after expanding a fragment * should bubble events from the portal to the parent * should not onMouseLeave when staying in the portal +* should not crash encountering low-priority tree src/renderers/dom/shared/__tests__/CSSProperty-test.js * should generate browser prefixes for its `isUnitlessNumber` diff --git a/scripts/jest/environment.js b/scripts/jest/environment.js index 6b0c38fe49d7..98aa77b5591c 100644 --- a/scripts/jest/environment.js +++ b/scripts/jest/environment.js @@ -1,11 +1,13 @@ /* eslint-disable */ global.__DEV__ = true; -// For testing DOM Fiber, we synchronously invoke all the scheduling. +// For testing DOM Fiber. global.requestAnimationFrame = function(callback) { - callback(); + setTimeout(callback); }; global.requestIdleCallback = function(callback) { - callback({ timeRemaining() { return Infinity; } }); + setTimeout(() => { + callback({ timeRemaining() { return Infinity; } }); + }); }; diff --git a/src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js b/src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js index 990ad069d1e1..9abec3eedd1b 100644 --- a/src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js +++ b/src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js @@ -993,5 +993,14 @@ describe('ReactDOMFiber', () => { 'leave parent', // Only when we leave the portal does onMouseLeave fire. ]); }); + + it('should not crash encountering low-priority tree', () => { + ReactDOM.render( +