Skip to content

Commit 99f52a2

Browse files
committed
followup to facebook#15763, failing tests in ReactDOMTracing-test
It was me. I broke the build.
1 parent e1c5e87 commit 99f52a2

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

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

+40-38
Original file line numberDiff line numberDiff line change
@@ -538,53 +538,55 @@ 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-
});
541+
TestUtils.act(() => {
542+
SchedulerTracing.unstable_trace('initialization', 0, () => {
543+
interaction = Array.from(SchedulerTracing.unstable_getCurrent())[0];
544+
// This render is only CPU bound. Nothing suspends.
545+
root.render(<App />);
546+
});
546547

547-
expect(Scheduler).toFlushAndYieldThrough(['A']);
548+
expect(Scheduler).toFlushAndYieldThrough(['A']);
548549

549-
Scheduler.advanceTime(300);
550-
jest.advanceTimersByTime(300);
550+
Scheduler.advanceTime(300);
551+
jest.advanceTimersByTime(300);
551552

552-
expect(Scheduler).toFlushAndYieldThrough(['B']);
553+
expect(Scheduler).toFlushAndYieldThrough(['B']);
553554

554-
Scheduler.advanceTime(300);
555-
jest.advanceTimersByTime(300);
555+
Scheduler.advanceTime(300);
556+
jest.advanceTimersByTime(300);
556557

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-
]);
558+
// Time has now elapsed for so long that we're just going to give up
559+
// rendering the rest of the content. So that we can at least show
560+
// something.
561+
expect(Scheduler).toFlushAndYieldThrough([
562+
'Loading C',
563+
'Commit A',
564+
'Commit B',
565+
'Commit Loading C',
566+
]);
566567

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-
);
568+
// Schedule an unrelated low priority update that shouldn't be included
569+
// in the previous interaction. This is meant to ensure that we don't
570+
// rely on the whole tree completing to cover up bugs.
571+
Scheduler.unstable_runWithPriority(
572+
Scheduler.unstable_IdlePriority,
573+
() => root.render(<App />),
574+
);
574575

575-
expect(onInteractionTraced).toHaveBeenCalledTimes(1);
576-
expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
577-
interaction,
578-
);
579-
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
576+
expect(onInteractionTraced).toHaveBeenCalledTimes(1);
577+
expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
578+
interaction,
579+
);
580+
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
580581

581-
// Then we do a second pass to commit the last item.
582-
expect(Scheduler).toFlushAndYieldThrough(['C', 'Commit C']);
582+
// Then we do a second pass to commit the last item.
583+
expect(Scheduler).toFlushAndYieldThrough(['C', 'Commit C']);
583584

584-
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
585-
expect(
586-
onInteractionScheduledWorkCompleted,
587-
).toHaveBeenLastNotifiedOfInteraction(interaction);
585+
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
586+
expect(
587+
onInteractionScheduledWorkCompleted,
588+
).toHaveBeenLastNotifiedOfInteraction(interaction);
589+
});
588590
});
589591
});
590592

0 commit comments

Comments
 (0)