diff --git a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js
index 6e724fd0a5679..9a9f57ccd20b4 100644
--- a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js
+++ b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js
@@ -370,7 +370,7 @@ describe('ReactSuspense', () => {
await LazyClass;
- expect(Scheduler).toFlushExpired(['Hi', 'Did mount: Hi']);
+ expect(Scheduler).toFlushUntilNextPaint(['Hi', 'Did mount: Hi']);
expect(root).toMatchRenderedOutput('Hi');
});
@@ -729,7 +729,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(100);
expect(Scheduler).toHaveYielded(['Promise resolved [B:1]']);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushUntilNextPaint([
'B:1',
'Unmount [Loading...]',
// Should be a mount, not an update
@@ -748,7 +748,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(100);
expect(Scheduler).toHaveYielded(['Promise resolved [B:2]']);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushUntilNextPaint([
'B:2',
'Unmount [Loading...]',
'Update [B:2]',
@@ -786,7 +786,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
- expect(Scheduler).toFlushExpired(['A']);
+ expect(Scheduler).toFlushUntilNextPaint(['A']);
expect(root).toMatchRenderedOutput('Stateful: 1A');
root.update();
@@ -804,7 +804,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
- expect(Scheduler).toFlushExpired(['B']);
+ expect(Scheduler).toFlushUntilNextPaint(['B']);
expect(root).toMatchRenderedOutput('Stateful: 2B');
});
@@ -846,7 +846,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
- expect(Scheduler).toFlushExpired(['A']);
+ expect(Scheduler).toFlushUntilNextPaint(['A']);
expect(root).toMatchRenderedOutput('Stateful: 1A');
root.update();
@@ -871,7 +871,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
- expect(Scheduler).toFlushExpired(['B']);
+ expect(Scheduler).toFlushUntilNextPaint(['B']);
expect(root).toMatchRenderedOutput('Stateful: 2B');
});
@@ -951,7 +951,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(500);
expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
- expect(Scheduler).toFlushExpired(['A', 'Did commit: A']);
+ expect(Scheduler).toFlushUntilNextPaint(['A', 'Did commit: A']);
});
it('retries when an update is scheduled on a timed out tree', () => {
@@ -1038,7 +1038,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [Child 1]']);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushUntilNextPaint([
'Child 1',
'Suspend! [Child 2]',
'Suspend! [Child 3]',
@@ -1047,12 +1047,15 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [Child 2]']);
- expect(Scheduler).toFlushExpired(['Child 2', 'Suspend! [Child 3]']);
+ expect(Scheduler).toFlushUntilNextPaint([
+ 'Child 2',
+ 'Suspend! [Child 3]',
+ ]);
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [Child 3]']);
- expect(Scheduler).toFlushExpired(['Child 3']);
+ expect(Scheduler).toFlushUntilNextPaint(['Child 3']);
expect(root).toMatchRenderedOutput(
['Child 1', 'Child 2', 'Child 3'].join(''),
);
@@ -1113,7 +1116,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [Tab: 0]']);
- expect(Scheduler).toFlushExpired(['Tab: 0']);
+ expect(Scheduler).toFlushUntilNextPaint(['Tab: 0']);
expect(root).toMatchRenderedOutput('Tab: 0 + sibling');
act(() => setTab(1));
@@ -1126,7 +1129,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [Tab: 1]']);
- expect(Scheduler).toFlushExpired(['Tab: 1']);
+ expect(Scheduler).toFlushUntilNextPaint(['Tab: 1']);
expect(root).toMatchRenderedOutput('Tab: 1 + sibling');
act(() => setTab(2));
@@ -1139,7 +1142,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [Tab: 2]']);
- expect(Scheduler).toFlushExpired(['Tab: 2']);
+ expect(Scheduler).toFlushUntilNextPaint(['Tab: 2']);
expect(root).toMatchRenderedOutput('Tab: 2 + sibling');
});
@@ -1177,7 +1180,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [A:0]']);
- expect(Scheduler).toFlushExpired(['A:0']);
+ expect(Scheduler).toFlushUntilNextPaint(['A:0']);
expect(root).toMatchRenderedOutput('A:0');
act(() => setStep(1));
@@ -1215,7 +1218,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushUntilNextPaint([
'A',
// The promises for B and C have now been thrown twice
'Suspend! [B]',
@@ -1226,7 +1229,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushUntilNextPaint([
// Even though the promise for B was thrown twice, we should only
// re-render once.
'B',
@@ -1238,7 +1241,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [C]']);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushUntilNextPaint([
// Even though the promise for C was thrown three times, we should only
// re-render once.
'C',
@@ -1280,7 +1283,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [A]']);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushUntilNextPaint([
'A',
// The promises for B and C have now been thrown twice
'Suspend! [B]',
@@ -1291,7 +1294,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [B]']);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushUntilNextPaint([
// Even though the promise for B was thrown twice, we should only
// re-render once.
'B',
@@ -1393,7 +1396,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [default]']);
- expect(Scheduler).toFlushExpired(['default']);
+ expect(Scheduler).toFlushUntilNextPaint(['default']);
expect(root).toMatchRenderedOutput('default');
act(() => setValue('new value'));
@@ -1401,7 +1404,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [new value]']);
- expect(Scheduler).toFlushExpired(['new value']);
+ expect(Scheduler).toFlushUntilNextPaint(['new value']);
expect(root).toMatchRenderedOutput('new value');
});
@@ -1450,7 +1453,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [default]']);
- expect(Scheduler).toFlushExpired(['default']);
+ expect(Scheduler).toFlushUntilNextPaint(['default']);
expect(root).toMatchRenderedOutput('default');
act(() => setValue('new value'));
@@ -1458,7 +1461,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [new value]']);
- expect(Scheduler).toFlushExpired(['new value']);
+ expect(Scheduler).toFlushUntilNextPaint(['new value']);
expect(root).toMatchRenderedOutput('new value');
});
@@ -1506,7 +1509,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [default]']);
- expect(Scheduler).toFlushExpired(['default']);
+ expect(Scheduler).toFlushUntilNextPaint(['default']);
expect(root).toMatchRenderedOutput('default');
act(() => setValue('new value'));
@@ -1514,7 +1517,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [new value]']);
- expect(Scheduler).toFlushExpired(['new value']);
+ expect(Scheduler).toFlushUntilNextPaint(['new value']);
expect(root).toMatchRenderedOutput('new value');
});
@@ -1558,7 +1561,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [default]']);
- expect(Scheduler).toFlushExpired(['default']);
+ expect(Scheduler).toFlushUntilNextPaint(['default']);
expect(root).toMatchRenderedOutput('default');
act(() => setValue('new value'));
@@ -1566,7 +1569,7 @@ describe('ReactSuspense', () => {
jest.advanceTimersByTime(1000);
expect(Scheduler).toHaveYielded(['Promise resolved [new value]']);
- expect(Scheduler).toFlushExpired(['new value']);
+ expect(Scheduler).toFlushUntilNextPaint(['new value']);
expect(root).toMatchRenderedOutput('new value');
});
});
diff --git a/packages/react/src/__tests__/ReactProfiler-test.internal.js b/packages/react/src/__tests__/ReactProfiler-test.internal.js
index 93347b1ac2f9f..ff2897141b57f 100644
--- a/packages/react/src/__tests__/ReactProfiler-test.internal.js
+++ b/packages/react/src/__tests__/ReactProfiler-test.internal.js
@@ -4306,7 +4306,7 @@ describe('Profiler', () => {
await resourcePromise;
expect(Scheduler).toHaveYielded(['Promise resolved [loaded]']);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushUntilNextPaint([
'onPostCommit',
'AsyncText [loaded]',
]);
@@ -4370,7 +4370,7 @@ describe('Profiler', () => {
await resourcePromise;
expect(Scheduler).toHaveYielded(['Promise resolved [loaded]']);
- expect(Scheduler).toFlushExpired(['onPostCommit', 'render']);
+ expect(Scheduler).toFlushUntilNextPaint(['onPostCommit', 'render']);
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
@@ -4575,7 +4575,7 @@ describe('Profiler', () => {
await originalPromise;
expect(Scheduler).toHaveYielded(['Promise resolved [loaded]']);
- expect(Scheduler).toFlushExpired(['AsyncText [loaded]']);
+ expect(Scheduler).toFlushUntilNextPaint(['AsyncText [loaded]']);
expect(renderer.toJSON()).toEqual(['loaded', 'updated']);
expect(Scheduler).toFlushAndYield(['onPostCommit']);
diff --git a/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js b/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
index d2f52dea1b11a..33454da6649d2 100644
--- a/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
+++ b/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
@@ -198,7 +198,7 @@ describe('ReactProfiler DevTools integration', () => {
root.update();
// Update B should not instantly expire.
- expect(Scheduler).toFlushExpired([]);
+ expect(Scheduler).toFlushAndYieldThrough([]);
expect(Scheduler).toFlushAndYield(['B']);
expect(root).toMatchRenderedOutput('B');
diff --git a/packages/scheduler/src/__tests__/SchedulerMock-test.js b/packages/scheduler/src/__tests__/SchedulerMock-test.js
index e8da8ee53d69a..c4bcee2061814 100644
--- a/packages/scheduler/src/__tests__/SchedulerMock-test.js
+++ b/packages/scheduler/src/__tests__/SchedulerMock-test.js
@@ -117,14 +117,14 @@ describe('Scheduler', () => {
// Advance by just a bit more to expire the user blocking callbacks
Scheduler.unstable_advanceTime(1);
- expect(Scheduler).toFlushExpired([
+ expect(Scheduler).toFlushAndYieldThrough([
'B (did timeout: true)',
'C (did timeout: true)',
]);
// Expire A
Scheduler.unstable_advanceTime(4600);
- expect(Scheduler).toFlushExpired(['A (did timeout: true)']);
+ expect(Scheduler).toFlushAndYieldThrough(['A (did timeout: true)']);
// Flush the rest without expiring
expect(Scheduler).toFlushAndYield([
diff --git a/packages/scheduler/src/forks/SchedulerMock.js b/packages/scheduler/src/forks/SchedulerMock.js
index ef72933db563d..9d97c425308ea 100644
--- a/packages/scheduler/src/forks/SchedulerMock.js
+++ b/packages/scheduler/src/forks/SchedulerMock.js
@@ -414,6 +414,7 @@ function cancelHostTimeout(): void {
function shouldYieldToHost(): boolean {
if (
+ (expectedNumberOfYields === 0 && yieldedValues === null) ||
(expectedNumberOfYields !== -1 &&
yieldedValues !== null &&
yieldedValues.length >= expectedNumberOfYields) ||