Skip to content

Commit 1c13974

Browse files
threepointonerickhanlonii
authored andcommitted
followup to facebook#15763, fix failing test in ReactDOMTracing-test (facebook#15972)
* followup to facebook#15763, failing tests in ReactDOMTracing-test It was me. I broke the build. * [ignore] add a newline to trigger a build
1 parent 9554c89 commit 1c13974

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

packages/react/src/__tests__/ReactDOMTracing-test.internal.js

+41-38
Original file line numberDiff line numberDiff line change
@@ -538,53 +538,56 @@ describe('ReactDOMTracing', () => {
538538
const root = ReactDOM.unstable_createRoot(container);
539539

540540
let interaction;
541-
SchedulerTracing.unstable_trace('initialization', 0, () => {
542-
interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0];
543-
// This render is only CPU bound. Nothing suspends.
544-
root.render(<App />);
545-
});
546541

547-
expect(Scheduler).toFlushAndYieldThrough(['A']);
542+
TestUtils.act(() => {
543+
SchedulerTracing.unstable_trace('initialization', 0, () => {
544+
interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0];
545+
// This render is only CPU bound. Nothing suspends.
546+
root.render(<App />);
547+
});
548548

549-
Scheduler.advanceTime(300);
550-
jest.advanceTimersByTime(300);
549+
expect(Scheduler).toFlushAndYieldThrough(['A']);
551550

552-
expect(Scheduler).toFlushAndYieldThrough(['B']);
551+
Scheduler.advanceTime(300);
552+
jest.advanceTimersByTime(300);
553553

554-
Scheduler.advanceTime(300);
555-
jest.advanceTimersByTime(300);
554+
expect(Scheduler).toFlushAndYieldThrough(['B']);
556555

557-
// Time has now elapsed for so long that we're just going to give up
558-
// rendering the rest of the content. So that we can at least show
559-
// something.
560-
expect(Scheduler).toFlushAndYieldThrough([
561-
'Loading C',
562-
'Commit A',
563-
'Commit B',
564-
'Commit Loading C',
565-
]);
556+
Scheduler.advanceTime(300);
557+
jest.advanceTimersByTime(300);
566558

567-
// Schedule an unrelated low priority update that shouldn't be included
568-
// in the previous interaction. This is meant to ensure that we don't
569-
// rely on the whole tree completing to cover up bugs.
570-
Scheduler.unstable_runWithPriority(
571-
Scheduler.unstable_IdlePriority,
572-
() => root.render(<App />),
573-
);
559+
// Time has now elapsed for so long that we're just going to give up
560+
// rendering the rest of the content. So that we can at least show
561+
// something.
562+
expect(Scheduler).toFlushAndYieldThrough([
563+
'Loading C',
564+
'Commit A',
565+
'Commit B',
566+
'Commit Loading C',
567+
]);
574568

575-
expect(onInteractionTraced).toHaveBeenCalledTimes(1);
576-
expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
577-
interaction,
578-
);
579-
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
569+
// Schedule an unrelated low priority update that shouldn't be included
570+
// in the previous interaction. This is meant to ensure that we don't
571+
// rely on the whole tree completing to cover up bugs.
572+
Scheduler.unstable_runWithPriority(
573+
Scheduler.unstable_IdlePriority,
574+
() => root.render(<App />),
575+
);
580576

581-
// Then we do a second pass to commit the last item.
582-
expect(Scheduler).toFlushAndYieldThrough(['C', 'Commit C']);
577+
expect(onInteractionTraced).toHaveBeenCalledTimes(1);
578+
expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
579+
interaction,
580+
);
581+
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
583582

584-
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
585-
expect(
586-
onInteractionScheduledWorkCompleted,
587-
).toHaveBeenLastNotifiedOfInteraction(interaction);
583+
// Then we do a second pass to commit the last item.
584+
expect(Scheduler).toFlushAndYieldThrough(['C', 'Commit C']);
585+
586+
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
587+
expect(
588+
onInteractionScheduledWorkCompleted,
589+
).toHaveBeenLastNotifiedOfInteraction(interaction);
590+
});
588591
});
589592
});
590593

0 commit comments

Comments
 (0)