Skip to content

Commit e9b6832

Browse files
committed
SchedulerMock.unstable_yieldValue -> SchedulerMock.log
(This only affects our own internal repo; it's not a public API.) I think most of us agree this is a less confusing name. It's possible someone will confuse it with `console.log`. If that becomes a problem we can warn in dev or something.
1 parent 0cba581 commit e9b6832

File tree

97 files changed

+2125
-2659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2125
-2659
lines changed

packages/internal-test-utils/ReactInternalTestUtils.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {equals} from '@jest/expect-utils';
1313
import enqueueTask from './enqueueTask';
1414

1515
function assertYieldsWereCleared(Scheduler) {
16-
const actualYields = Scheduler.unstable_clearYields();
16+
const actualYields = Scheduler.unstable_clearLog();
1717
if (actualYields.length !== 0) {
1818
const error = Error(
1919
'The event log is not empty. Call assertLog(...) first.',
@@ -45,14 +45,14 @@ export async function waitFor(expectedLog) {
4545
SchedulerMock.unstable_flushNumberOfYields(
4646
expectedLog.length - actualLog.length,
4747
);
48-
actualLog.push(...SchedulerMock.unstable_clearYields());
48+
actualLog.push(...SchedulerMock.unstable_clearLog());
4949
if (expectedLog.length > actualLog.length) {
5050
// Continue flushing until we've logged the expected number of items.
5151
} else {
5252
// Once we've reached the expected sequence, wait one more microtask to
5353
// flush any remaining synchronous work.
5454
await waitForMicrotasks();
55-
actualLog.push(...SchedulerMock.unstable_clearYields());
55+
actualLog.push(...SchedulerMock.unstable_clearLog());
5656
break;
5757
}
5858
} else {
@@ -91,7 +91,7 @@ export async function waitForAll(expectedLog) {
9191
SchedulerMock.unstable_flushAllWithoutAsserting();
9292
} while (true);
9393

94-
const actualLog = SchedulerMock.unstable_clearYields();
94+
const actualLog = SchedulerMock.unstable_clearLog();
9595
if (equals(actualLog, expectedLog)) {
9696
return;
9797
}
@@ -166,7 +166,7 @@ export async function waitForPaint(expectedLog) {
166166
await waitForMicrotasks();
167167
}
168168

169-
const actualLog = SchedulerMock.unstable_clearYields();
169+
const actualLog = SchedulerMock.unstable_clearLog();
170170
if (equals(actualLog, expectedLog)) {
171171
return;
172172
}
@@ -180,7 +180,7 @@ ${diff(expectedLog, actualLog)}
180180
}
181181

182182
export function assertLog(expectedLog) {
183-
const actualLog = SchedulerMock.unstable_clearYields();
183+
const actualLog = SchedulerMock.unstable_clearLog();
184184
if (equals(actualLog, expectedLog)) {
185185
return;
186186
}

packages/internal-test-utils/__tests__/ReactInternalTestUtils-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const Scheduler = require('scheduler/unstable_mock');
2626
describe('ReactInternalTestUtils', () => {
2727
test('waitFor', async () => {
2828
const Yield = ({id}) => {
29-
Scheduler.unstable_yieldValue(id);
29+
Scheduler.log(id);
3030
return id;
3131
};
3232

@@ -51,7 +51,7 @@ describe('ReactInternalTestUtils', () => {
5151

5252
test('waitForAll', async () => {
5353
const Yield = ({id}) => {
54-
Scheduler.unstable_yieldValue(id);
54+
Scheduler.log(id);
5555
return id;
5656
};
5757

@@ -72,7 +72,7 @@ describe('ReactInternalTestUtils', () => {
7272

7373
test('waitForThrow', async () => {
7474
const Yield = ({id}) => {
75-
Scheduler.unstable_yieldValue(id);
75+
Scheduler.log(id);
7676
return id;
7777
};
7878

@@ -113,7 +113,7 @@ describe('ReactInternalTestUtils', () => {
113113
function App({prop}) {
114114
const deferred = useDeferredValue(prop);
115115
const text = `Urgent: ${prop}, Deferred: ${deferred}`;
116-
Scheduler.unstable_yieldValue(text);
116+
Scheduler.log(text);
117117
return text;
118118
}
119119

@@ -137,7 +137,7 @@ describe('ReactInternalTestUtils', () => {
137137

138138
test('assertLog', async () => {
139139
const Yield = ({id}) => {
140-
Scheduler.unstable_yieldValue(id);
140+
Scheduler.log(id);
141141
return id;
142142
};
143143

packages/jest-react/src/JestReact.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function captureAssertion(fn) {
2929

3030
function assertYieldsWereCleared(root) {
3131
const Scheduler = root._Scheduler;
32-
const actualYields = Scheduler.unstable_clearYields();
32+
const actualYields = Scheduler.unstable_clearLog();
3333
if (actualYields.length !== 0) {
3434
const error = Error(
3535
'Log of yielded values is not empty. ' +

packages/react-cache/src/__tests__/ReactCacheOld-test.internal.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,12 @@ describe('ReactCache', () => {
5454
listeners = [{resolve, reject}];
5555
setTimeout(() => {
5656
if (textResourceShouldFail) {
57-
Scheduler.unstable_yieldValue(
58-
`Promise rejected [${text}]`,
59-
);
57+
Scheduler.log(`Promise rejected [${text}]`);
6058
status = 'rejected';
6159
value = new Error('Failed to load: ' + text);
6260
listeners.forEach(listener => listener.reject(value));
6361
} else {
64-
Scheduler.unstable_yieldValue(
65-
`Promise resolved [${text}]`,
66-
);
62+
Scheduler.log(`Promise resolved [${text}]`);
6763
status = 'resolved';
6864
value = text;
6965
listeners.forEach(listener => listener.resolve(value));
@@ -93,21 +89,21 @@ describe('ReactCache', () => {
9389
});
9490

9591
function Text(props) {
96-
Scheduler.unstable_yieldValue(props.text);
92+
Scheduler.log(props.text);
9793
return props.text;
9894
}
9995

10096
function AsyncText(props) {
10197
const text = props.text;
10298
try {
10399
TextResource.read([props.text, props.ms]);
104-
Scheduler.unstable_yieldValue(text);
100+
Scheduler.log(text);
105101
return text;
106102
} catch (promise) {
107103
if (typeof promise.then === 'function') {
108-
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
104+
Scheduler.log(`Suspend! [${text}]`);
109105
} else {
110-
Scheduler.unstable_yieldValue(`Error! [${text}]`);
106+
Scheduler.log(`Error! [${text}]`);
111107
}
112108
throw promise;
113109
}
@@ -171,7 +167,7 @@ describe('ReactCache', () => {
171167
});
172168

173169
function App() {
174-
Scheduler.unstable_yieldValue('App');
170+
Scheduler.log('App');
175171
return BadTextResource.read(['Hi', 100]);
176172
}
177173

@@ -322,13 +318,13 @@ describe('ReactCache', () => {
322318
const text = props.text;
323319
try {
324320
const actualText = BadTextResource.read([props.text, props.ms]);
325-
Scheduler.unstable_yieldValue(actualText);
321+
Scheduler.log(actualText);
326322
return actualText;
327323
} catch (promise) {
328324
if (typeof promise.then === 'function') {
329-
Scheduler.unstable_yieldValue(`Suspend! [${text}]`);
325+
Scheduler.log(`Suspend! [${text}]`);
330326
} else {
331-
Scheduler.unstable_yieldValue(`Error! [${text}]`);
327+
Scheduler.log(`Error! [${text}]`);
332328
}
333329
throw promise;
334330
}

packages/react-client/src/__tests__/ReactFlight-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ describe('ReactFlight', () => {
799799
}
800800

801801
function ClientDoubler({el}) {
802-
Scheduler.unstable_yieldValue('ClientDoubler');
802+
Scheduler.log('ClientDoubler');
803803
return (
804804
<>
805805
{el}
@@ -990,10 +990,10 @@ describe('ReactFlight', () => {
990990

991991
function Bar() {
992992
if (!promise.unsuspend) {
993-
Scheduler.unstable_yieldValue('suspended');
993+
Scheduler.log('suspended');
994994
throw promise;
995995
}
996-
Scheduler.unstable_yieldValue('rendered');
996+
Scheduler.log('rendered');
997997
const context = React.useContext(ServerContext);
998998
return context;
999999
}
@@ -1027,7 +1027,7 @@ describe('ReactFlight', () => {
10271027
);
10281028

10291029
function ClientBar() {
1030-
Scheduler.unstable_yieldValue('ClientBar');
1030+
Scheduler.log('ClientBar');
10311031
const context = React.useContext(ServerContext);
10321032
return <span>{context}</span>;
10331033
}

0 commit comments

Comments
 (0)