15
let React;
16
let ReactFeatureFlags;
17
let ReactNoop;
18
+let Scheduler;
19
let SchedulerTracing;
20
let useState;
21
let useReducer;
41
ReactFeatureFlags.enableSchedulerTracing = true;
42
React = require('react');
43
ReactNoop = require('react-noop-renderer');
44
+ Scheduler = require('scheduler');
45
SchedulerTracing = require('scheduler/tracing');
46
useState = React.useState;
47
useReducer = React.useReducer;
597
it('simple mount and update', () => {
598
function Counter(props) {
599
useEffect(() => {
598
- ReactNoop.yield(`Did commit [${props.count}]`);
600
+ ReactNoop.yield(`Passive effect [${props.count}]`);
601
});
602
return <Text text={'Count: ' + props.count} />;
603
}
602
- ReactNoop.render(<Counter count={0} />);
603
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
604
+ ReactNoop.render(<Counter count={0} />, () =>
605
+ ReactNoop.yield('Sync effect'),
606
+ );
607
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
608
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
605
- ReactNoop.flushPassiveEffects();
606
- expect(ReactNoop).toHaveYielded(['Did commit [0]']);
609
+ // Effects are deferred until after the commit
610
+ expect(ReactNoop).toFlushAndYield(['Passive effect [0]']);
611
608
- ReactNoop.render(<Counter count={1} />);
609
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
612
+ ReactNoop.render(<Counter count={1} />, () =>
613
+ ReactNoop.yield('Sync effect'),
614
+ );
615
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
616
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
617
// Effects are deferred until after the commit
612
- ReactNoop.flushPassiveEffects();
613
- expect(ReactNoop).toHaveYielded(['Did commit [1]']);
618
+ expect(ReactNoop).toFlushAndYield(['Passive effect [1]']);
619
});
620
621
it('flushes passive effects even with sibling deletions', () => {
633
}
634
let passive = <PassiveEffect key="p" />;
635
ReactNoop.render([<LayoutEffect key="l" />, passive]);
631
- expect(ReactNoop).toFlushAndYield(['Layout', 'Passive', 'Layout effect']);
636
+ expect(ReactNoop).toFlushAndYieldThrough([
637
+ 'Layout',
638
+ 'Passive',
639
+ 'Layout effect',
640
+ ]);
641
expect(ReactNoop.getChildren()).toEqual([
642
span('Layout'),
643
span('Passive'),
742
});
743
return <Text text={props.count} />;
744
}
736
- ReactNoop.render(<Counter count={0} />);
737
- expect(ReactNoop).toFlushAndYield([0]);
745
+ ReactNoop.render(<Counter count={0} />, () =>
746
+ ReactNoop.yield('Sync effect'),
747
+ );
748
+ expect(ReactNoop).toFlushAndYieldThrough([0, 'Sync effect']);
749
expect(ReactNoop.getChildren()).toEqual([span(0)]);
750
751
// Before the effects have a chance to flush, schedule another update
741
- ReactNoop.render(<Counter count={1} />);
752
+ ReactNoop.render(<Counter count={1} />, () =>
753
+ ReactNoop.yield('Sync effect'),
754
+ );
755
expect(ReactNoop).toHaveYielded([
756
// The previous effect flushes before the reconciliation
757
'Committed state when effect was fired: 0',
758
]);
746
- expect(ReactNoop).toFlushAndYield([1]);
759
+ expect(ReactNoop).toFlushAndYieldThrough([1, 'Sync effect']);
760
expect(ReactNoop.getChildren()).toEqual([span(1)]);
761
762
ReactNoop.flushPassiveEffects();
778
);
779
return <Text text={'Count: ' + count} />;
780
}
768
- ReactNoop.render(<Counter count={0} />);
769
- expect(ReactNoop).toFlushAndYield(['Count: (empty)']);
781
+ ReactNoop.render(<Counter count={0} />, () =>
782
+ ReactNoop.yield('Sync effect'),
783
+ );
784
+ expect(ReactNoop).toFlushAndYieldThrough([
785
+ 'Count: (empty)',
786
+ 'Sync effect',
787
+ ]);
788
expect(ReactNoop.getChildren()).toEqual([span('Count: (empty)')]);
789
ReactNoop.flushPassiveEffects();
790
expect(ReactNoop).toHaveYielded(['Schedule update [0]']);
791
expect(ReactNoop).toFlushAndYield(['Count: 0']);
792
775
- ReactNoop.render(<Counter count={1} />);
776
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
793
+ ReactNoop.render(<Counter count={1} />, () =>
794
+ ReactNoop.yield('Sync effect'),
795
+ );
796
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
797
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
798
ReactNoop.flushPassiveEffects();
799
expect(ReactNoop).toHaveYielded(['Schedule update [1]']);
812
);
813
return <Text text={'Count: ' + count} />;
814
}
795
- ReactNoop.render(<Counter count={0} />);
796
- expect(ReactNoop).toFlushAndYield(['Count: (empty)']);
815
+ ReactNoop.render(<Counter count={0} />, () =>
816
+ ReactNoop.yield('Sync effect'),
817
+ );
818
+ expect(ReactNoop).toFlushAndYieldThrough([
819
+ 'Count: (empty)',
820
+ 'Sync effect',
821
+ ]);
822
expect(ReactNoop.getChildren()).toEqual([span('Count: (empty)')]);
823
824
// Rendering again should flush the previous commit's effects
800
- ReactNoop.render(<Counter count={1} />);
825
+ ReactNoop.render(<Counter count={1} />, () =>
826
+ ReactNoop.yield('Sync effect'),
827
+ );
828
expect(ReactNoop).toHaveYielded(['Schedule update [0]']);
829
expect(ReactNoop).toFlushAndYieldThrough(['Count: 0']);
830
expect(ReactNoop.getChildren()).toEqual([span('Count: (empty)')]);
831
805
- ReactNoop.batchedUpdates(() => {
806
- expect(ReactNoop).toFlushAndYield([]);
807
- });
808
-
832
+ expect(ReactNoop).toFlushAndYieldThrough(['Sync effect']);
833
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
834
835
ReactNoop.flushPassiveEffects();
850
return <Text text={'Count: ' + count} />;
851
}
852
829
- ReactNoop.render(<Counter count={0} />);
830
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
853
+ ReactNoop.render(<Counter count={0} />, () =>
854
+ ReactNoop.yield('Sync effect'),
855
+ );
856
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
857
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
858
859
// Enqueuing this update forces the passive effect to be flushed --
895
tracingEvent.name,
896
tracingEvent.timestamp,
897
() => {
872
- ReactNoop.render(<Counter count={0} />);
898
+ ReactNoop.render(<Counter count={0} />, () =>
899
+ ReactNoop.yield('Sync effect'),
900
+ );
901
},
902
);
875
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
903
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
904
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
905
906
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(0);
964
);
965
return <Text text={'Count: ' + count} />;
966
}
939
- ReactNoop.render(<Counter count={0} />);
940
- expect(ReactNoop).toFlushAndYield(['Count: (empty)']);
967
+ ReactNoop.render(<Counter count={0} />, () =>
968
+ ReactNoop.yield('Sync effect'),
969
+ );
970
+ expect(ReactNoop).toFlushAndYieldThrough([
971
+ 'Count: (empty)',
972
+ 'Sync effect',
973
+ ]);
974
expect(ReactNoop.getChildren()).toEqual([span('Count: (empty)')]);
975
976
expect(() => {
988
});
989
return <Text text={'Count: ' + props.count} />;
990
}
958
- ReactNoop.render(<Counter count={0} />);
959
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
991
+ ReactNoop.render(<Counter count={0} />, () =>
992
+ ReactNoop.yield('Sync effect'),
993
+ );
994
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
995
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
996
ReactNoop.flushPassiveEffects();
997
expect(ReactNoop).toHaveYielded(['Did create [0]']);
998
964
- ReactNoop.render(<Counter count={1} />);
965
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
999
+ ReactNoop.render(<Counter count={1} />, () =>
1000
+ ReactNoop.yield('Sync effect'),
1001
+ );
1002
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1003
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1004
ReactNoop.flushPassiveEffects();
1005
expect(ReactNoop).toHaveYielded(['Did destroy [0]', 'Did create [1]']);
1015
});
1016
return <Text text={'Count: ' + props.count} />;
1017
}
981
- ReactNoop.render(<Counter count={0} />);
982
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
1018
+ ReactNoop.render(<Counter count={0} />, () =>
1019
+ ReactNoop.yield('Sync effect'),
1020
+ );
1021
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1022
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1023
ReactNoop.flushPassiveEffects();
1024
expect(ReactNoop).toHaveYielded(['Did create [0]']);
1038
}, []);
1039
return <Text text={'Count: ' + props.count} />;
1040
}
1002
- ReactNoop.render(<Counter count={0} />);
1003
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
1041
+ ReactNoop.render(<Counter count={0} />, () =>
1042
+ ReactNoop.yield('Sync effect'),
1043
+ );
1044
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1045
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1046
ReactNoop.flushPassiveEffects();
1047
expect(ReactNoop).toHaveYielded(['Did create [0]']);
1048
1008
- ReactNoop.render(<Counter count={1} />);
1009
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
1049
+ ReactNoop.render(<Counter count={1} />, () =>
1050
+ ReactNoop.yield('Sync effect'),
1051
+ );
1052
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1053
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1054
ReactNoop.flushPassiveEffects();
1055
expect(ReactNoop).toHaveYielded([]);
1070
useEffect(effect);
1071
return <Text text={'Count: ' + props.count} />;
1072
}
1030
- ReactNoop.render(<Counter count={0} />);
1031
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
1073
+ ReactNoop.render(<Counter count={0} />, () =>
1074
+ ReactNoop.yield('Sync effect'),
1075
+ );
1076
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1077
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1078
ReactNoop.flushPassiveEffects();
1079
expect(ReactNoop).toHaveYielded(['Did create']);
1080
1036
- ReactNoop.render(<Counter count={1} />);
1037
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
1081
+ ReactNoop.render(<Counter count={1} />, () =>
1082
+ ReactNoop.yield('Sync effect'),
1083
+ );
1084
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1085
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1086
ReactNoop.flushPassiveEffects();
1087
expect(ReactNoop).toHaveYielded(['Did destroy', 'Did create']);
1105
);
1106
return <Text text={text} />;
1107
}
1061
- ReactNoop.render(<Counter label="Count" count={0} />);
1062
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
1108
+ ReactNoop.render(<Counter label="Count" count={0} />, () =>
1109
+ ReactNoop.yield('Sync effect'),
1110
+ );
1111
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1112
ReactNoop.flushPassiveEffects();
1113
expect(ReactNoop).toHaveYielded(['Did create [Count: 0]']);
1114
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1115
1067
- ReactNoop.render(<Counter label="Count" count={1} />);
1116
+ ReactNoop.render(<Counter label="Count" count={1} />, () =>
1117
+ ReactNoop.yield('Sync effect'),
1118
+ );
1119
// Count changed
1069
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
1120
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1121
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1122
ReactNoop.flushPassiveEffects();
1123
expect(ReactNoop).toHaveYielded([
1125
'Did create [Count: 1]',
1126
]);
1127
1077
- ReactNoop.render(<Counter label="Count" count={1} />);
1128
+ ReactNoop.render(<Counter label="Count" count={1} />, () =>
1129
+ ReactNoop.yield('Sync effect'),
1130
+ );
1131
// Nothing changed, so no effect should have fired
1079
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
1132
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1133
ReactNoop.flushPassiveEffects();
1134
expect(ReactNoop).toHaveYielded([]);
1135
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1136
1084
- ReactNoop.render(<Counter label="Total" count={1} />);
1137
+ ReactNoop.render(<Counter label="Total" count={1} />, () =>
1138
+ ReactNoop.yield('Sync effect'),
1139
+ );
1140
// Label changed
1086
- expect(ReactNoop).toFlushAndYield(['Total: 1']);
1141
+ expect(ReactNoop).toFlushAndYieldThrough(['Total: 1', 'Sync effect']);
1142
expect(ReactNoop.getChildren()).toEqual([span('Total: 1')]);
1143
ReactNoop.flushPassiveEffects();
1144
expect(ReactNoop).toHaveYielded([
1157
});
1158
return <Text text={'Count: ' + props.count} />;
1159
}
1105
- ReactNoop.render(<Counter count={0} />);
1106
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
1160
+ ReactNoop.render(<Counter count={0} />, () =>
1161
+ ReactNoop.yield('Sync effect'),
1162
+ );
1163
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1164
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1165
ReactNoop.flushPassiveEffects();
1166
expect(ReactNoop).toHaveYielded(['Did commit 1 [0]', 'Did commit 2 [0]']);
1167
1111
- ReactNoop.render(<Counter count={1} />);
1112
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
1168
+ ReactNoop.render(<Counter count={1} />, () =>
1169
+ ReactNoop.yield('Sync effect'),
1170
+ );
1171
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1172
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1173
ReactNoop.flushPassiveEffects();
1174
expect(ReactNoop).toHaveYielded(['Did commit 1 [1]', 'Did commit 2 [1]']);
1190
});
1191
return <Text text={'Count: ' + props.count} />;
1192
}
1134
- ReactNoop.render(<Counter count={0} />);
1135
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
1193
+ ReactNoop.render(<Counter count={0} />, () =>
1194
+ ReactNoop.yield('Sync effect'),
1195
+ );
1196
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1197
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1198
ReactNoop.flushPassiveEffects();
1199
expect(ReactNoop).toHaveYielded(['Mount A [0]', 'Mount B [0]']);
1200
1140
- ReactNoop.render(<Counter count={1} />);
1141
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
1201
+ ReactNoop.render(<Counter count={1} />, () =>
1202
+ ReactNoop.yield('Sync effect'),
1203
+ );
1204
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1205
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1206
ReactNoop.flushPassiveEffects();
1207
expect(ReactNoop).toHaveYielded([
1231
});
1232
return <Text text={'Count: ' + props.count} />;
1233
}
1171
- ReactNoop.render(<Counter count={0} />);
1172
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
1234
+ ReactNoop.render(<Counter count={0} />, () =>
1235
+ ReactNoop.yield('Sync effect'),
1236
+ );
1237
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1238
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1239
expect(() => ReactNoop.flushPassiveEffects()).toThrow('Oops');
1240
expect(ReactNoop).toHaveYielded([
1267
});
1268
return <Text text={'Count: ' + props.count} />;
1269
}
1205
- ReactNoop.render(<Counter count={0} />);
1206
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
1270
+ ReactNoop.render(<Counter count={0} />, () =>
1271
+ ReactNoop.yield('Sync effect'),
1272
+ );
1273
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1274
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1275
ReactNoop.flushPassiveEffects();
1276
expect(ReactNoop).toHaveYielded(['Mount A [0]', 'Mount B [0]']);
1277
1278
// This update will trigger an errror
1212
- ReactNoop.render(<Counter count={1} />);
1213
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
1279
+ ReactNoop.render(<Counter count={1} />, () =>
1280
+ ReactNoop.yield('Sync effect'),
1281
+ );
1282
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1283
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1284
expect(() => ReactNoop.flushPassiveEffects()).toThrow('Oops');
1285
expect(ReactNoop).toHaveYielded([
1313
});
1314
return <Text text={'Count: ' + props.count} />;
1315
}
1247
- ReactNoop.render(<Counter count={0} />);
1248
- expect(ReactNoop).toFlushAndYield(['Count: 0']);
1316
+ ReactNoop.render(<Counter count={0} />, () =>
1317
+ ReactNoop.yield('Sync effect'),
1318
+ );
1319
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1320
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1321
ReactNoop.flushPassiveEffects();
1322
expect(ReactNoop).toHaveYielded(['Mount A [0]', 'Mount B [0]']);
1323
1324
// This update will trigger an errror
1254
- ReactNoop.render(<Counter count={1} />);
1255
- expect(ReactNoop).toFlushAndYield(['Count: 1']);
1325
+ ReactNoop.render(<Counter count={1} />, () =>
1326
+ ReactNoop.yield('Sync effect'),
1327
+ );
1328
+ expect(ReactNoop).toFlushAndYieldThrough(['Count: 1', 'Sync effect']);
1329
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1330
expect(() => ReactNoop.flushPassiveEffects()).toThrow('Oops');
1331
expect(ReactNoop).toHaveYielded([
1346
}
1347
Counter = memo(Counter);
1348
1276
- ReactNoop.render(<Counter count={0} />);
1277
- expect(ReactNoop).toFlushAndYield(['Count: 0', 'Mount: 0']);
1349
+ ReactNoop.render(<Counter count={0} />, () =>
1350
+ ReactNoop.yield('Sync effect'),
1351
+ );
1352
+ expect(ReactNoop).toFlushAndYieldThrough([
1353
+ 'Count: 0',
1354
+ 'Mount: 0',
1355
+ 'Sync effect',
1356
+ ]);
1357
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1358
1280
- ReactNoop.render(<Counter count={1} />);
1281
- expect(ReactNoop).toFlushAndYield(['Count: 1', 'Unmount: 0', 'Mount: 1']);
1359
+ ReactNoop.render(<Counter count={1} />, () =>
1360
+ ReactNoop.yield('Sync effect'),
1361
+ );
1362
+ expect(ReactNoop).toFlushAndYieldThrough([
1363
+ 'Count: 1',
1364
+ 'Unmount: 0',
1365
+ 'Mount: 1',
1366
+ 'Sync effect',
1367
+ ]);
1368
expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]);
1369
1370
ReactNoop.render(null);
1285
- expect(ReactNoop).toFlushAndYield(['Unmount: 1']);
1371
+ expect(ReactNoop).toFlushAndYieldThrough(['Unmount: 1']);
1372
expect(ReactNoop.getChildren()).toEqual([]);
1373
});
1374
});
1376
describe('useLayoutEffect', () => {
1377
it('fires layout effects after the host has been mutated', () => {
1378
function getCommittedText() {
1293
- const yields = ReactNoop.unstable_clearYields();
1379
+ const yields = Scheduler.unstable_clearYields();
1380
const children = ReactNoop.getChildren();
1381
ReactNoop.yield(yields);
1382
if (children === null) {
1392
return <Text text={props.count} />;
1393
}
1394
1309
- ReactNoop.render(<Counter count={0} />);
1310
- expect(ReactNoop).toFlushAndYield([[0], 'Current: 0']);
1395
+ ReactNoop.render(<Counter count={0} />, () =>
1396
+ ReactNoop.yield('Sync effect'),
1397
+ );
1398
+ expect(ReactNoop).toFlushAndYieldThrough([
1399
+ [0],
1400
+ 'Current: 0',
1401
+ 'Sync effect',
1402
+ ]);
1403
expect(ReactNoop.getChildren()).toEqual([span(0)]);
1404
1313
- ReactNoop.render(<Counter count={1} />);
1314
- expect(ReactNoop).toFlushAndYield([[1], 'Current: 1']);
1405
+ ReactNoop.render(<Counter count={1} />, () =>
1406
+ ReactNoop.yield('Sync effect'),
1407
+ );
1408
+ expect(ReactNoop).toFlushAndYieldThrough([
1409
+ [1],
1410
+ 'Current: 1',
1411
+ 'Sync effect',
1412
+ ]);
1413
expect(ReactNoop.getChildren()).toEqual([span(1)]);
1414
});
1415
1436
return null;
1437
}
1438
1341
- ReactNoop.render(<Counter count={0} />);
1342
- expect(ReactNoop).toFlushAndYield(['Mount layout [current: 0]']);
1439
+ ReactNoop.render(<Counter count={0} />, () =>
1440
+ ReactNoop.yield('Sync effect'),
1441
+ );
1442
+ expect(ReactNoop).toFlushAndYieldThrough([
1443
+ 'Mount layout [current: 0]',
1444
+ 'Sync effect',
1445
+ ]);
1446
expect(committedText).toEqual('0');
1447
1345
- ReactNoop.render(<Counter count={1} />);
1448
+ ReactNoop.render(<Counter count={1} />, () =>
1449
+ ReactNoop.yield('Sync effect'),
1450
+ );
1451
expect(ReactNoop).toHaveYielded(['Mount normal [current: 0]']);
1347
- expect(ReactNoop).toFlushAndYield([
1452
+ expect(ReactNoop).toFlushAndYieldThrough([
1453
'Unmount layout [current: 0]',
1454
'Mount layout [current: 1]',
1455
+ 'Sync effect',
1456
]);
1457
expect(committedText).toEqual('1');
1458
1929
return null;
1930
}
1931
1826
- ReactNoop.render(<App showMore={false} />);
1827
- expect(ReactNoop).toFlushAndYield([]);
1932
+ ReactNoop.render(<App showMore={false} />, () =>
1933
+ ReactNoop.yield('Sync effect'),
1934
+ );
1935
+ expect(ReactNoop).toFlushAndYieldThrough(['Sync effect']);
1936
ReactNoop.flushPassiveEffects();
1937
expect(ReactNoop).toHaveYielded(['Mount A']);
1938