Skip to content

Commit

Permalink
followup to #15763, fix failing test in ReactDOMTracing-test (#15972)
Browse files Browse the repository at this point in the history
* followup to #15763, failing tests in ReactDOMTracing-test

It was me. I broke the build.

* [ignore] add a newline to trigger a build
  • Loading branch information
threepointone committed Jun 24, 2019
1 parent e1c5e87 commit 04b77c6
Showing 1 changed file with 41 additions and 38 deletions.
79 changes: 41 additions & 38 deletions packages/react/src/__tests__/ReactDOMTracing-test.internal.js
Expand Up @@ -538,53 +538,56 @@ describe('ReactDOMTracing', () => {
const root = ReactDOM.unstable_createRoot(container);

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

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

Scheduler.advanceTime(300);
jest.advanceTimersByTime(300);
expect(Scheduler).toFlushAndYieldThrough(['A']);

expect(Scheduler).toFlushAndYieldThrough(['B']);
Scheduler.advanceTime(300);
jest.advanceTimersByTime(300);

Scheduler.advanceTime(300);
jest.advanceTimersByTime(300);
expect(Scheduler).toFlushAndYieldThrough(['B']);

// Time has now elapsed for so long that we're just going to give up
// rendering the rest of the content. So that we can at least show
// something.
expect(Scheduler).toFlushAndYieldThrough([
'Loading C',
'Commit A',
'Commit B',
'Commit Loading C',
]);
Scheduler.advanceTime(300);
jest.advanceTimersByTime(300);

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

expect(onInteractionTraced).toHaveBeenCalledTimes(1);
expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
interaction,
);
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();
// Schedule an unrelated low priority update that shouldn't be included
// in the previous interaction. This is meant to ensure that we don't
// rely on the whole tree completing to cover up bugs.
Scheduler.unstable_runWithPriority(
Scheduler.unstable_IdlePriority,
() => root.render(<App />),
);

// Then we do a second pass to commit the last item.
expect(Scheduler).toFlushAndYieldThrough(['C', 'Commit C']);
expect(onInteractionTraced).toHaveBeenCalledTimes(1);
expect(onInteractionTraced).toHaveBeenLastNotifiedOfInteraction(
interaction,
);
expect(onInteractionScheduledWorkCompleted).not.toHaveBeenCalled();

expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
expect(
onInteractionScheduledWorkCompleted,
).toHaveBeenLastNotifiedOfInteraction(interaction);
// Then we do a second pass to commit the last item.
expect(Scheduler).toFlushAndYieldThrough(['C', 'Commit C']);

expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
expect(
onInteractionScheduledWorkCompleted,
).toHaveBeenLastNotifiedOfInteraction(interaction);
});
});
});

Expand Down

0 comments on commit 04b77c6

Please sign in to comment.