Skip to content

Commit c691734

Browse files
author
Brian Vaughn
authored
Fixed broken Profiler test (#19894)
1 parent 87c023b commit c691734

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

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

+12-15
Original file line numberDiff line numberDiff line change
@@ -3477,16 +3477,16 @@ describe('Profiler', () => {
34773477
}
34783478
}
34793479

3480-
const onPostCommit = jest.fn(() => {
3481-
Scheduler.unstable_yieldValue('onPostCommit');
3480+
const onCommit = jest.fn(() => {
3481+
Scheduler.unstable_yieldValue('onCommit');
34823482
});
3483-
ReactNoop.act(async () => {
3483+
await ReactNoop.act(async () => {
34843484
SchedulerTracing.unstable_trace(
34853485
interaction.name,
34863486
Scheduler.unstable_now(),
34873487
() => {
34883488
ReactNoop.render(
3489-
<React.Profiler id="test-profiler" onPostCommit={onPostCommit}>
3489+
<React.Profiler id="test-profiler" onCommit={onCommit}>
34903490
<React.Suspense fallback={<Text text="Loading..." />}>
34913491
<AsyncText text="Async" ms={20000} />
34923492
</React.Suspense>
@@ -3511,13 +3511,13 @@ describe('Profiler', () => {
35113511
'Text [Loading...]',
35123512
'Text [Sync]',
35133513
'Monkey',
3514-
'onPostCommit',
3514+
'onCommit',
35153515
]);
35163516
// Should have committed the placeholder.
35173517
expect(ReactNoop.getChildrenAsJSX()).toEqual('Loading...Sync');
3518-
expect(onPostCommit).toHaveBeenCalledTimes(1);
3518+
expect(onCommit).toHaveBeenCalledTimes(1);
35193519

3520-
let call = onPostCommit.mock.calls[0];
3520+
let call = onCommit.mock.calls[0];
35213521
expect(call[0]).toEqual('test-profiler');
35223522
expect(call[4]).toMatchInteractions(
35233523
ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [],
@@ -3528,20 +3528,17 @@ describe('Profiler', () => {
35283528

35293529
// An unrelated update in the middle shouldn't affect things...
35303530
monkey.current.forceUpdate();
3531-
expect(Scheduler).toFlushAndYield(['Monkey', 'onPostCommit']);
3532-
expect(onPostCommit).toHaveBeenCalledTimes(2);
3531+
expect(Scheduler).toFlushAndYield(['Monkey', 'onCommit']);
3532+
expect(onCommit).toHaveBeenCalledTimes(2);
35333533

35343534
// Once the promise resolves, we render the suspended view
35353535
await awaitableAdvanceTimers(20000);
35363536
expect(Scheduler).toHaveYielded(['Promise resolved [Async]']);
3537-
expect(Scheduler).toFlushAndYield([
3538-
'AsyncText [Async]',
3539-
'onPostCommit',
3540-
]);
3537+
expect(Scheduler).toFlushAndYield(['AsyncText [Async]', 'onCommit']);
35413538
expect(ReactNoop.getChildrenAsJSX()).toEqual('AsyncSync');
3542-
expect(onPostCommit).toHaveBeenCalledTimes(3);
3539+
expect(onCommit).toHaveBeenCalledTimes(3);
35433540

3544-
call = onPostCommit.mock.calls[2];
3541+
call = onCommit.mock.calls[2];
35453542
expect(call[0]).toEqual('test-profiler');
35463543
expect(call[4]).toMatchInteractions(
35473544
ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [],

0 commit comments

Comments
 (0)