Cleaned up some tests
Brian Vaughn committed
May 22, 2019 at 08:05 UTC
d09299bf85198305e088ecd353f8b3b21c3d710a
5 files changed
+990
-656
src/__tests__/__snapshots__/profilingCache-test.js.snap
+870
-496
@@ -149,182 +149,181 @@ Object {
149
`;
150
151
exports[`ProfilingCache should collect data for each commit: imported data 1`] = `
152
-"{
153
- \\"version\\": 5,
154
- \\"dataForRoots\\": [
155
- {
156
- \\"commitData\\": [
157
- {
158
- \\"duration\\": 12,
159
- \\"fiberActualDurations\\": [
160
- [
152
+Object {
153
+ "dataForRoots": Array [
154
+ Object {
155
+ "commitData": Array [
156
+ Object {
157
+ "duration": 12,
158
+ "fiberActualDurations": Array [
159
+ Array [
160
1,
162
- 12
161
+ 12,
162
],
164
- [
163
+ Array [
164
2,
166
- 12
165
+ 12,
166
],
168
- [
167
+ Array [
168
3,
170
- 0
169
+ 0,
170
],
172
- [
171
+ Array [
172
4,
174
- 1
173
+ 1,
174
],
176
- [
175
+ Array [
176
5,
178
- 1
179
- ]
177
+ 1,
178
+ ],
179
],
181
- \\"fiberSelfDurations\\": [
182
- [
180
+ "fiberSelfDurations": Array [
181
+ Array [
182
1,
184
- 0
183
+ 0,
184
],
186
- [
185
+ Array [
186
2,
188
- 10
187
+ 10,
188
],
190
- [
189
+ Array [
190
3,
192
- 0
191
+ 0,
192
],
194
- [
193
+ Array [
194
4,
196
- 1
195
+ 1,
196
],
198
- [
197
+ Array [
198
5,
200
- 1
201
- ]
199
+ 1,
200
+ ],
201
],
203
- \\"interactionIDs\\": [],
204
- \\"priorityLevel\\": \\"Immediate\\",
205
- \\"screenshot\\": null,
206
- \\"timestamp\\": 12
202
+ "interactionIDs": Array [],
203
+ "priorityLevel": "Immediate",
204
+ "screenshot": null,
205
+ "timestamp": 12,
206
},
208
- {
209
- \\"duration\\": 13,
210
- \\"fiberActualDurations\\": [
211
- [
207
+ Object {
208
+ "duration": 13,
209
+ "fiberActualDurations": Array [
210
+ Array [
211
3,
213
- 0
212
+ 0,
213
],
215
- [
214
+ Array [
215
4,
217
- 1
216
+ 1,
217
],
219
- [
218
+ Array [
219
6,
221
- 2
220
+ 2,
221
],
223
- [
222
+ Array [
223
2,
225
- 13
224
+ 13,
225
],
227
- [
226
+ Array [
227
1,
229
- 13
230
- ]
228
+ 13,
229
+ ],
230
],
232
- \\"fiberSelfDurations\\": [
233
- [
231
+ "fiberSelfDurations": Array [
232
+ Array [
233
3,
235
- 0
234
+ 0,
235
],
237
- [
236
+ Array [
237
4,
239
- 1
238
+ 1,
239
],
241
- [
240
+ Array [
241
6,
243
- 2
242
+ 2,
243
],
245
- [
244
+ Array [
245
2,
247
- 10
246
+ 10,
247
],
249
- [
248
+ Array [
249
1,
251
- 0
252
- ]
250
+ 0,
251
+ ],
252
],
254
- \\"interactionIDs\\": [],
255
- \\"priorityLevel\\": \\"Immediate\\",
256
- \\"screenshot\\": null,
257
- \\"timestamp\\": 25
253
+ "interactionIDs": Array [],
254
+ "priorityLevel": "Immediate",
255
+ "screenshot": null,
256
+ "timestamp": 25,
257
},
259
- {
260
- \\"duration\\": 10,
261
- \\"fiberActualDurations\\": [
262
- [
258
+ Object {
259
+ "duration": 10,
260
+ "fiberActualDurations": Array [
261
+ Array [
262
3,
264
- 0
263
+ 0,
264
],
266
- [
265
+ Array [
266
2,
268
- 10
267
+ 10,
268
],
270
- [
269
+ Array [
270
1,
272
- 10
273
- ]
271
+ 10,
272
+ ],
273
],
275
- \\"fiberSelfDurations\\": [
276
- [
274
+ "fiberSelfDurations": Array [
275
+ Array [
276
3,
278
- 0
277
+ 0,
278
],
280
- [
279
+ Array [
280
2,
282
- 10
281
+ 10,
282
],
284
- [
283
+ Array [
284
1,
286
- 0
287
- ]
285
+ 0,
286
+ ],
287
],
289
- \\"interactionIDs\\": [],
290
- \\"priorityLevel\\": \\"Immediate\\",
291
- \\"screenshot\\": null,
292
- \\"timestamp\\": 35
288
+ "interactionIDs": Array [],
289
+ "priorityLevel": "Immediate",
290
+ "screenshot": null,
291
+ "timestamp": 35,
292
},
294
- {
295
- \\"duration\\": 10,
296
- \\"fiberActualDurations\\": [
297
- [
293
+ Object {
294
+ "duration": 10,
295
+ "fiberActualDurations": Array [
296
+ Array [
297
2,
299
- 10
298
+ 10,
299
],
301
- [
300
+ Array [
301
1,
303
- 10
304
- ]
302
+ 10,
303
+ ],
304
],
306
- \\"fiberSelfDurations\\": [
307
- [
305
+ "fiberSelfDurations": Array [
306
+ Array [
307
2,
309
- 10
308
+ 10,
309
],
311
- [
310
+ Array [
311
1,
313
- 0
314
- ]
312
+ 0,
313
+ ],
314
],
316
- \\"interactionIDs\\": [],
317
- \\"priorityLevel\\": \\"Immediate\\",
318
- \\"screenshot\\": null,
319
- \\"timestamp\\": 45
320
- }
315
+ "interactionIDs": Array [],
316
+ "priorityLevel": "Immediate",
317
+ "screenshot": null,
318
+ "timestamp": 45,
319
+ },
320
],
322
- \\"displayName\\": \\"Parent\\",
323
- \\"initialTreeBaseDurations\\": [],
324
- \\"interactionCommits\\": [],
325
- \\"interactions\\": [],
326
- \\"operations\\": [
327
- [
321
+ "displayName": "Parent",
322
+ "initialTreeBaseDurations": Array [],
323
+ "interactionCommits": Array [],
324
+ "interactions": Array [],
325
+ "operations": Array [
326
+ Array [
327
1,
328
1,
329
17,
@@ -392,9 +391,9 @@ exports[`ProfilingCache should collect data for each commit: imported data 1`] =
391
0,
392
4,
393
5,
395
- 1000
394
+ 1000,
395
],
397
- [
396
+ Array [
397
1,
398
1,
399
8,
@@ -428,9 +427,9 @@ exports[`ProfilingCache should collect data for each commit: imported data 1`] =
427
5,
428
4,
429
1,
431
- 14000
430
+ 14000,
431
],
433
- [
432
+ Array [
433
1,
434
1,
435
0,
@@ -448,22 +447,23 @@ exports[`ProfilingCache should collect data for each commit: imported data 1`] =
447
5,
448
4,
449
1,
451
- 11000
450
+ 11000,
451
],
453
- [
452
+ Array [
453
1,
454
1,
455
0,
456
2,
457
1,
459
- 3
460
- ]
458
+ 3,
459
+ ],
460
],
462
- \\"rootID\\": 1,
463
- \\"snapshots\\": []
464
- }
465
- ]
466
-}"
461
+ "rootID": 1,
462
+ "snapshots": Array [],
463
+ },
464
+ ],
465
+ "version": 5,
466
+}
467
`;
468
469
exports[`ProfilingCache should collect data for each rendered fiber: FiberCommits: element 2 1`] = `
@@ -502,155 +502,154 @@ Array [
502
`;
503
504
exports[`ProfilingCache should collect data for each rendered fiber: imported data 1`] = `
505
-"{
506
- \\"version\\": 5,
507
- \\"dataForRoots\\": [
508
- {
509
- \\"commitData\\": [
510
- {
511
- \\"duration\\": 11,
512
- \\"fiberActualDurations\\": [
513
- [
505
+Object {
506
+ "dataForRoots": Array [
507
+ Object {
508
+ "commitData": Array [
509
+ Object {
510
+ "duration": 11,
511
+ "fiberActualDurations": Array [
512
+ Array [
513
1,
515
- 11
514
+ 11,
515
],
517
- [
516
+ Array [
517
2,
519
- 11
518
+ 11,
519
],
521
- [
520
+ Array [
521
3,
523
- 0
522
+ 0,
523
],
525
- [
524
+ Array [
525
4,
527
- 1
528
- ]
526
+ 1,
527
+ ],
528
],
530
- \\"fiberSelfDurations\\": [
531
- [
529
+ "fiberSelfDurations": Array [
530
+ Array [
531
1,
533
- 0
532
+ 0,
533
],
535
- [
534
+ Array [
535
2,
537
- 10
536
+ 10,
537
],
539
- [
538
+ Array [
539
3,
541
- 0
540
+ 0,
541
],
543
- [
542
+ Array [
543
4,
545
- 1
546
- ]
544
+ 1,
545
+ ],
546
],
548
- \\"interactionIDs\\": [],
549
- \\"priorityLevel\\": \\"Immediate\\",
550
- \\"screenshot\\": null,
551
- \\"timestamp\\": 11
547
+ "interactionIDs": Array [],
548
+ "priorityLevel": "Immediate",
549
+ "screenshot": null,
550
+ "timestamp": 11,
551
},
553
- {
554
- \\"duration\\": 11,
555
- \\"fiberActualDurations\\": [
556
- [
552
+ Object {
553
+ "duration": 11,
554
+ "fiberActualDurations": Array [
555
+ Array [
556
3,
558
- 0
557
+ 0,
558
],
560
- [
559
+ Array [
560
5,
562
- 1
561
+ 1,
562
],
564
- [
563
+ Array [
564
2,
566
- 11
565
+ 11,
566
],
568
- [
567
+ Array [
568
1,
570
- 11
571
- ]
569
+ 11,
570
+ ],
571
],
573
- \\"fiberSelfDurations\\": [
574
- [
572
+ "fiberSelfDurations": Array [
573
+ Array [
574
3,
576
- 0
575
+ 0,
576
],
578
- [
577
+ Array [
578
5,
580
- 1
579
+ 1,
580
],
582
- [
581
+ Array [
582
2,
584
- 10
583
+ 10,
584
],
586
- [
585
+ Array [
586
1,
588
- 0
589
- ]
587
+ 0,
588
+ ],
589
],
591
- \\"interactionIDs\\": [],
592
- \\"priorityLevel\\": \\"Immediate\\",
593
- \\"screenshot\\": null,
594
- \\"timestamp\\": 22
590
+ "interactionIDs": Array [],
591
+ "priorityLevel": "Immediate",
592
+ "screenshot": null,
593
+ "timestamp": 22,
594
},
596
- {
597
- \\"duration\\": 13,
598
- \\"fiberActualDurations\\": [
599
- [
595
+ Object {
596
+ "duration": 13,
597
+ "fiberActualDurations": Array [
598
+ Array [
599
3,
601
- 0
600
+ 0,
601
],
603
- [
602
+ Array [
603
5,
605
- 1
604
+ 1,
605
],
607
- [
606
+ Array [
607
6,
609
- 2
608
+ 2,
609
],
611
- [
610
+ Array [
611
2,
613
- 13
612
+ 13,
613
],
615
- [
614
+ Array [
615
1,
617
- 13
618
- ]
616
+ 13,
617
+ ],
618
],
620
- \\"fiberSelfDurations\\": [
621
- [
619
+ "fiberSelfDurations": Array [
620
+ Array [
621
3,
623
- 0
622
+ 0,
623
],
625
- [
624
+ Array [
625
5,
627
- 1
626
+ 1,
627
],
629
- [
628
+ Array [
629
6,
631
- 2
630
+ 2,
631
],
633
- [
632
+ Array [
633
2,
635
- 10
634
+ 10,
635
],
637
- [
636
+ Array [
637
1,
639
- 0
640
- ]
638
+ 0,
639
+ ],
640
],
642
- \\"interactionIDs\\": [],
643
- \\"priorityLevel\\": \\"Immediate\\",
644
- \\"screenshot\\": null,
645
- \\"timestamp\\": 35
646
- }
641
+ "interactionIDs": Array [],
642
+ "priorityLevel": "Immediate",
643
+ "screenshot": null,
644
+ "timestamp": 35,
645
+ },
646
],
648
- \\"displayName\\": \\"Parent\\",
649
- \\"initialTreeBaseDurations\\": [],
650
- \\"interactionCommits\\": [],
651
- \\"interactions\\": [],
652
- \\"operations\\": [
653
- [
647
+ "displayName": "Parent",
648
+ "initialTreeBaseDurations": Array [],
649
+ "interactionCommits": Array [],
650
+ "interactions": Array [],
651
+ "operations": Array [
652
+ Array [
653
1,
654
1,
655
15,
@@ -706,9 +705,9 @@ exports[`ProfilingCache should collect data for each rendered fiber: imported da
705
0,
706
4,
707
4,
709
- 1000
708
+ 1000,
709
],
711
- [
710
+ Array [
711
1,
712
1,
713
8,
@@ -741,9 +740,9 @@ exports[`ProfilingCache should collect data for each rendered fiber: imported da
740
4,
741
4,
742
1,
744
- 12000
743
+ 12000,
744
],
746
- [
745
+ Array [
746
1,
747
1,
748
8,
@@ -777,17 +776,18 @@ exports[`ProfilingCache should collect data for each rendered fiber: imported da
776
4,
777
4,
778
1,
780
- 14000
781
- ]
779
+ 14000,
780
+ ],
781
],
783
- \\"rootID\\": 1,
784
- \\"snapshots\\": []
785
- }
786
- ]
787
-}"
782
+ "rootID": 1,
783
+ "snapshots": Array [],
784
+ },
785
+ ],
786
+ "version": 5,
787
+}
788
`;
789
790
-exports[`ProfilingCache should collect data for each root: ProfilingSummary 1`] = `
790
+exports[`ProfilingCache should collect data for each root (including ones added or mounted after profiling started): Data for root Parent 1`] = `
791
Object {
792
"commitData": Array [
793
Object {
@@ -795,14 +795,14 @@ Object {
795
"fiberActualDurations": Map {
796
3 => 0,
797
4 => 1,
798
- 6 => 2,
798
+ 10 => 2,
799
2 => 13,
800
1 => 13,
801
},
802
"fiberSelfDurations": Map {
803
3 => 0,
804
4 => 1,
805
- 6 => 2,
805
+ 10 => 2,
806
2 => 10,
807
1 => 0,
808
},
@@ -826,7 +826,7 @@ Object {
826
"interactionIDs": Array [],
827
"priorityLevel": "Immediate",
828
"screenshot": null,
829
- "timestamp": 23,
829
+ "timestamp": 34,
830
},
831
Object {
832
"duration": 10,
@@ -841,7 +841,7 @@ Object {
841
"interactionIDs": Array [],
842
"priorityLevel": "Immediate",
843
"screenshot": null,
844
- "timestamp": 33,
844
+ "timestamp": 44,
845
},
846
],
847
"displayName": "Parent",
@@ -868,14 +868,14 @@ Object {
868
1,
869
50,
870
1,
871
- 6,
871
+ 10,
872
5,
873
2,
874
2,
875
1,
876
2,
877
4,
878
- 6,
878
+ 10,
879
2000,
880
4,
881
2,
@@ -885,7 +885,7 @@ Object {
885
4,
886
3,
887
4,
888
- 6,
888
+ 10,
889
5,
890
4,
891
1,
@@ -897,7 +897,7 @@ Object {
897
0,
898
2,
899
2,
900
- 6,
900
+ 10,
901
4,
902
4,
903
2,
@@ -967,153 +967,318 @@ Object {
967
}
968
`;
969
970
-exports[`ProfilingCache should collect data for each root: imported data 1`] = `
971
-"{
972
- \\"version\\": 5,
973
- \\"dataForRoots\\": [
974
- {
975
- \\"commitData\\": [
976
- {
977
- \\"duration\\": 13,
978
- \\"fiberActualDurations\\": [
979
- [
970
+exports[`ProfilingCache should collect data for each root (including ones added or mounted after profiling started): Data for root Parent 2`] = `
971
+Object {
972
+ "commitData": Array [
973
+ Object {
974
+ "duration": 11,
975
+ "fiberActualDurations": Map {
976
+ 11 => 11,
977
+ 12 => 11,
978
+ 13 => 0,
979
+ 14 => 1,
980
+ },
981
+ "fiberSelfDurations": Map {
982
+ 11 => 0,
983
+ 12 => 10,
984
+ 13 => 0,
985
+ 14 => 1,
986
+ },
987
+ "interactionIDs": Array [],
988
+ "priorityLevel": "Immediate",
989
+ "screenshot": null,
990
+ "timestamp": 24,
991
+ },
992
+ ],
993
+ "displayName": "Parent",
994
+ "initialTreeBaseDurations": Map {},
995
+ "interactionCommits": Map {},
996
+ "interactions": Map {},
997
+ "operations": Array [
998
+ Uint32Array [
999
+ 1,
1000
+ 11,
1001
+ 15,
1002
+ 6,
1003
+ 80,
1004
+ 97,
1005
+ 114,
1006
+ 101,
1007
+ 110,
1008
+ 116,
1009
+ 5,
1010
+ 67,
1011
+ 104,
1012
+ 105,
1013
+ 108,
1014
+ 100,
1015
+ 1,
1016
+ 48,
1017
+ 1,
1018
+ 11,
1019
+ 11,
1020
+ 1,
1021
+ 1,
1022
+ 4,
1023
+ 11,
1024
+ 11000,
1025
+ 1,
1026
+ 12,
1027
+ 5,
1028
+ 11,
1029
+ 0,
1030
+ 1,
1031
+ 0,
1032
+ 4,
1033
+ 12,
1034
+ 11000,
1035
+ 1,
1036
+ 13,
1037
+ 5,
1038
+ 12,
1039
+ 12,
1040
+ 2,
1041
+ 3,
1042
+ 4,
1043
+ 13,
1044
+ 0,
1045
+ 1,
1046
+ 14,
1047
+ 8,
1048
+ 12,
1049
+ 12,
1050
+ 2,
1051
+ 0,
1052
+ 4,
1053
+ 14,
1054
+ 1000,
1055
+ ],
1056
+ ],
1057
+ "rootID": 11,
1058
+ "snapshots": Map {},
1059
+}
1060
+`;
1061
+
1062
+exports[`ProfilingCache should collect data for each root (including ones added or mounted after profiling started): Data for root Parent 3`] = `
1063
+Object {
1064
+ "commitData": Array [
1065
+ Object {
1066
+ "duration": 0,
1067
+ "fiberActualDurations": Map {},
1068
+ "fiberSelfDurations": Map {},
1069
+ "interactionIDs": Array [],
1070
+ "priorityLevel": "Immediate",
1071
+ "screenshot": null,
1072
+ "timestamp": 34,
1073
+ },
1074
+ ],
1075
+ "displayName": "Parent",
1076
+ "initialTreeBaseDurations": Map {
1077
+ 6 => 11,
1078
+ 7 => 11,
1079
+ 8 => 0,
1080
+ 9 => 1,
1081
+ },
1082
+ "interactionCommits": Map {},
1083
+ "interactions": Map {},
1084
+ "operations": Array [
1085
+ Uint32Array [
1086
+ 1,
1087
+ 6,
1088
+ 0,
1089
+ 2,
1090
+ 4,
1091
+ 9,
1092
+ 8,
1093
+ 7,
1094
+ 6,
1095
+ ],
1096
+ ],
1097
+ "rootID": 6,
1098
+ "snapshots": Map {
1099
+ 6 => Object {
1100
+ "children": Array [
1101
+ 7,
1102
+ ],
1103
+ "displayName": null,
1104
+ "id": 6,
1105
+ "key": null,
1106
+ "type": 11,
1107
+ },
1108
+ 7 => Object {
1109
+ "children": Array [
1110
+ 8,
1111
+ 9,
1112
+ ],
1113
+ "displayName": "Parent",
1114
+ "id": 7,
1115
+ "key": null,
1116
+ "type": 5,
1117
+ },
1118
+ 8 => Object {
1119
+ "children": Array [],
1120
+ "displayName": "Child",
1121
+ "id": 8,
1122
+ "key": "0",
1123
+ "type": 5,
1124
+ },
1125
+ 9 => Object {
1126
+ "children": Array [],
1127
+ "displayName": "Child",
1128
+ "id": 9,
1129
+ "key": null,
1130
+ "type": 8,
1131
+ },
1132
+ },
1133
+}
1134
+`;
1135
+
1136
+exports[`ProfilingCache should collect data for each root (including ones added or mounted after profiling started): imported data 1`] = `
1137
+Object {
1138
+ "dataForRoots": Array [
1139
+ Object {
1140
+ "commitData": Array [
1141
+ Object {
1142
+ "duration": 13,
1143
+ "fiberActualDurations": Array [
1144
+ Array [
1145
3,
981
- 0
1146
+ 0,
1147
],
983
- [
1148
+ Array [
1149
4,
985
- 1
1150
+ 1,
1151
],
987
- [
988
- 6,
989
- 2
1152
+ Array [
1153
+ 10,
1154
+ 2,
1155
],
991
- [
1156
+ Array [
1157
2,
993
- 13
1158
+ 13,
1159
],
995
- [
1160
+ Array [
1161
1,
997
- 13
998
- ]
1162
+ 13,
1163
+ ],
1164
],
1000
- \\"fiberSelfDurations\\": [
1001
- [
1165
+ "fiberSelfDurations": Array [
1166
+ Array [
1167
3,
1003
- 0
1168
+ 0,
1169
],
1005
- [
1170
+ Array [
1171
4,
1007
- 1
1172
+ 1,
1173
],
1009
- [
1010
- 6,
1011
- 2
1174
+ Array [
1175
+ 10,
1176
+ 2,
1177
],
1013
- [
1178
+ Array [
1179
2,
1015
- 10
1180
+ 10,
1181
],
1017
- [
1182
+ Array [
1183
1,
1019
- 0
1020
- ]
1184
+ 0,
1185
+ ],
1186
],
1022
- \\"interactionIDs\\": [],
1023
- \\"priorityLevel\\": \\"Immediate\\",
1024
- \\"screenshot\\": null,
1025
- \\"timestamp\\": 13
1187
+ "interactionIDs": Array [],
1188
+ "priorityLevel": "Immediate",
1189
+ "screenshot": null,
1190
+ "timestamp": 13,
1191
},
1027
- {
1028
- \\"duration\\": 10,
1029
- \\"fiberActualDurations\\": [
1030
- [
1192
+ Object {
1193
+ "duration": 10,
1194
+ "fiberActualDurations": Array [
1195
+ Array [
1196
3,
1032
- 0
1197
+ 0,
1198
],
1034
- [
1199
+ Array [
1200
2,
1036
- 10
1201
+ 10,
1202
],
1038
- [
1203
+ Array [
1204
1,
1040
- 10
1041
- ]
1205
+ 10,
1206
+ ],
1207
],
1043
- \\"fiberSelfDurations\\": [
1044
- [
1208
+ "fiberSelfDurations": Array [
1209
+ Array [
1210
3,
1046
- 0
1211
+ 0,
1212
],
1048
- [
1213
+ Array [
1214
2,
1050
- 10
1215
+ 10,
1216
],
1052
- [
1217
+ Array [
1218
1,
1054
- 0
1055
- ]
1219
+ 0,
1220
+ ],
1221
],
1057
- \\"interactionIDs\\": [],
1058
- \\"priorityLevel\\": \\"Immediate\\",
1059
- \\"screenshot\\": null,
1060
- \\"timestamp\\": 23
1222
+ "interactionIDs": Array [],
1223
+ "priorityLevel": "Immediate",
1224
+ "screenshot": null,
1225
+ "timestamp": 34,
1226
},
1062
- {
1063
- \\"duration\\": 10,
1064
- \\"fiberActualDurations\\": [
1065
- [
1227
+ Object {
1228
+ "duration": 10,
1229
+ "fiberActualDurations": Array [
1230
+ Array [
1231
2,
1067
- 10
1232
+ 10,
1233
],
1069
- [
1234
+ Array [
1235
1,
1071
- 10
1072
- ]
1236
+ 10,
1237
+ ],
1238
],
1074
- \\"fiberSelfDurations\\": [
1075
- [
1239
+ "fiberSelfDurations": Array [
1240
+ Array [
1241
2,
1077
- 10
1242
+ 10,
1243
],
1079
- [
1244
+ Array [
1245
1,
1081
- 0
1082
- ]
1246
+ 0,
1247
+ ],
1248
],
1084
- \\"interactionIDs\\": [],
1085
- \\"priorityLevel\\": \\"Immediate\\",
1086
- \\"screenshot\\": null,
1087
- \\"timestamp\\": 33
1088
- }
1249
+ "interactionIDs": Array [],
1250
+ "priorityLevel": "Immediate",
1251
+ "screenshot": null,
1252
+ "timestamp": 44,
1253
+ },
1254
],
1090
- \\"displayName\\": \\"Parent\\",
1091
- \\"initialTreeBaseDurations\\": [
1092
- [
1255
+ "displayName": "Parent",
1256
+ "initialTreeBaseDurations": Array [
1257
+ Array [
1258
1,
1094
- 12
1259
+ 12,
1260
],
1096
- [
1261
+ Array [
1262
2,
1098
- 12
1263
+ 12,
1264
],
1100
- [
1265
+ Array [
1266
3,
1102
- 0
1267
+ 0,
1268
],
1104
- [
1269
+ Array [
1270
4,
1106
- 1
1271
+ 1,
1272
],
1108
- [
1273
+ Array [
1274
5,
1110
- 1
1111
- ]
1275
+ 1,
1276
+ ],
1277
],
1113
- \\"interactionCommits\\": [],
1114
- \\"interactions\\": [],
1115
- \\"operations\\": [
1116
- [
1278
+ "interactionCommits": Array [],
1279
+ "interactions": Array [],
1280
+ "operations": Array [
1281
+ Array [
1282
1,
1283
1,
1284
8,
@@ -1126,14 +1291,14 @@ exports[`ProfilingCache should collect data for each root: imported data 1`] = `
1291
1,
1292
50,
1293
1,
1129
- 6,
1294
+ 10,
1295
5,
1296
2,
1297
2,
1298
1,
1299
2,
1300
4,
1136
- 6,
1301
+ 10,
1302
2000,
1303
4,
1304
2,
@@ -1143,19 +1308,19 @@ exports[`ProfilingCache should collect data for each root: imported data 1`] = `
1308
4,
1309
3,
1310
4,
1146
- 6,
1311
+ 10,
1312
5,
1313
4,
1314
1,
1150
- 14000
1315
+ 14000,
1316
],
1152
- [
1317
+ Array [
1318
1,
1319
1,
1320
0,
1321
2,
1322
2,
1158
- 6,
1323
+ 10,
1324
4,
1325
4,
1326
2,
@@ -1167,79 +1332,288 @@ exports[`ProfilingCache should collect data for each root: imported data 1`] = `
1332
5,
1333
4,
1334
1,
1170
- 11000
1335
+ 11000,
1336
],
1172
- [
1337
+ Array [
1338
1,
1339
1,
1340
0,
1341
2,
1342
1,
1178
- 3
1179
- ]
1343
+ 3,
1344
+ ],
1345
],
1181
- \\"rootID\\": 1,
1182
- \\"snapshots\\": [
1183
- [
1184
- 1,
1185
- {
1186
- \\"id\\": 1,
1187
- \\"children\\": [
1188
- 2
1189
- ],
1190
- \\"displayName\\": null,
1191
- \\"key\\": null,
1192
- \\"type\\": 11
1193
- }
1346
+ "rootID": 1,
1347
+ "snapshots": Array [
1348
+ Array [
1349
+ 1,
1350
+ Object {
1351
+ "children": Array [
1352
+ 2,
1353
+ ],
1354
+ "displayName": null,
1355
+ "id": 1,
1356
+ "key": null,
1357
+ "type": 11,
1358
+ },
1359
],
1195
- [
1360
+ Array [
1361
2,
1197
- {
1198
- \\"id\\": 2,
1199
- \\"children\\": [
1362
+ Object {
1363
+ "children": Array [
1364
3,
1365
4,
1202
- 5
1366
+ 5,
1367
],
1204
- \\"displayName\\": \\"Parent\\",
1205
- \\"key\\": null,
1206
- \\"type\\": 5
1207
- }
1368
+ "displayName": "Parent",
1369
+ "id": 2,
1370
+ "key": null,
1371
+ "type": 5,
1372
+ },
1373
],
1209
- [
1374
+ Array [
1375
3,
1211
- {
1212
- \\"id\\": 3,
1213
- \\"children\\": [],
1214
- \\"displayName\\": \\"Child\\",
1215
- \\"key\\": \\"0\\",
1216
- \\"type\\": 5
1217
- }
1376
+ Object {
1377
+ "children": Array [],
1378
+ "displayName": "Child",
1379
+ "id": 3,
1380
+ "key": "0",
1381
+ "type": 5,
1382
+ },
1383
],
1219
- [
1384
+ Array [
1385
4,
1221
- {
1222
- \\"id\\": 4,
1223
- \\"children\\": [],
1224
- \\"displayName\\": \\"Child\\",
1225
- \\"key\\": \\"1\\",
1226
- \\"type\\": 5
1227
- }
1386
+ Object {
1387
+ "children": Array [],
1388
+ "displayName": "Child",
1389
+ "id": 4,
1390
+ "key": "1",
1391
+ "type": 5,
1392
+ },
1393
],
1229
- [
1394
+ Array [
1395
5,
1231
- {
1232
- \\"id\\": 5,
1233
- \\"children\\": [],
1234
- \\"displayName\\": \\"Child\\",
1235
- \\"key\\": null,
1236
- \\"type\\": 8
1237
- }
1238
- ]
1239
- ]
1240
- }
1241
- ]
1242
-}"
1396
+ Object {
1397
+ "children": Array [],
1398
+ "displayName": "Child",
1399
+ "id": 5,
1400
+ "key": null,
1401
+ "type": 8,
1402
+ },
1403
+ ],
1404
+ ],
1405
+ },
1406
+ Object {
1407
+ "commitData": Array [
1408
+ Object {
1409
+ "duration": 11,
1410
+ "fiberActualDurations": Array [
1411
+ Array [
1412
+ 11,
1413
+ 11,
1414
+ ],
1415
+ Array [
1416
+ 12,
1417
+ 11,
1418
+ ],
1419
+ Array [
1420
+ 13,
1421
+ 0,
1422
+ ],
1423
+ Array [
1424
+ 14,
1425
+ 1,
1426
+ ],
1427
+ ],
1428
+ "fiberSelfDurations": Array [
1429
+ Array [
1430
+ 11,
1431
+ 0,
1432
+ ],
1433
+ Array [
1434
+ 12,
1435
+ 10,
1436
+ ],
1437
+ Array [
1438
+ 13,
1439
+ 0,
1440
+ ],
1441
+ Array [
1442
+ 14,
1443
+ 1,
1444
+ ],
1445
+ ],
1446
+ "interactionIDs": Array [],
1447
+ "priorityLevel": "Immediate",
1448
+ "screenshot": null,
1449
+ "timestamp": 24,
1450
+ },
1451
+ ],
1452
+ "displayName": "Parent",
1453
+ "initialTreeBaseDurations": Array [],
1454
+ "interactionCommits": Array [],
1455
+ "interactions": Array [],
1456
+ "operations": Array [
1457
+ Array [
1458
+ 1,
1459
+ 11,
1460
+ 15,
1461
+ 6,
1462
+ 80,
1463
+ 97,
1464
+ 114,
1465
+ 101,
1466
+ 110,
1467
+ 116,
1468
+ 5,
1469
+ 67,
1470
+ 104,
1471
+ 105,
1472
+ 108,
1473
+ 100,
1474
+ 1,
1475
+ 48,
1476
+ 1,
1477
+ 11,
1478
+ 11,
1479
+ 1,
1480
+ 1,
1481
+ 4,
1482
+ 11,
1483
+ 11000,
1484
+ 1,
1485
+ 12,
1486
+ 5,
1487
+ 11,
1488
+ 0,
1489
+ 1,
1490
+ 0,
1491
+ 4,
1492
+ 12,
1493
+ 11000,
1494
+ 1,
1495
+ 13,
1496
+ 5,
1497
+ 12,
1498
+ 12,
1499
+ 2,
1500
+ 3,
1501
+ 4,
1502
+ 13,
1503
+ 0,
1504
+ 1,
1505
+ 14,
1506
+ 8,
1507
+ 12,
1508
+ 12,
1509
+ 2,
1510
+ 0,
1511
+ 4,
1512
+ 14,
1513
+ 1000,
1514
+ ],
1515
+ ],
1516
+ "rootID": 11,
1517
+ "snapshots": Array [],
1518
+ },
1519
+ Object {
1520
+ "commitData": Array [
1521
+ Object {
1522
+ "duration": 0,
1523
+ "fiberActualDurations": Array [],
1524
+ "fiberSelfDurations": Array [],
1525
+ "interactionIDs": Array [],
1526
+ "priorityLevel": "Immediate",
1527
+ "screenshot": null,
1528
+ "timestamp": 34,
1529
+ },
1530
+ ],
1531
+ "displayName": "Parent",
1532
+ "initialTreeBaseDurations": Array [
1533
+ Array [
1534
+ 6,
1535
+ 11,
1536
+ ],
1537
+ Array [
1538
+ 7,
1539
+ 11,
1540
+ ],
1541
+ Array [
1542
+ 8,
1543
+ 0,
1544
+ ],
1545
+ Array [
1546
+ 9,
1547
+ 1,
1548
+ ],
1549
+ ],
1550
+ "interactionCommits": Array [],
1551
+ "interactions": Array [],
1552
+ "operations": Array [
1553
+ Array [
1554
+ 1,
1555
+ 6,
1556
+ 0,
1557
+ 2,
1558
+ 4,
1559
+ 9,
1560
+ 8,
1561
+ 7,
1562
+ 6,
1563
+ ],
1564
+ ],
1565
+ "rootID": 6,
1566
+ "snapshots": Array [
1567
+ Array [
1568
+ 6,
1569
+ Object {
1570
+ "children": Array [
1571
+ 7,
1572
+ ],
1573
+ "displayName": null,
1574
+ "id": 6,
1575
+ "key": null,
1576
+ "type": 11,
1577
+ },
1578
+ ],
1579
+ Array [
1580
+ 7,
1581
+ Object {
1582
+ "children": Array [
1583
+ 8,
1584
+ 9,
1585
+ ],
1586
+ "displayName": "Parent",
1587
+ "id": 7,
1588
+ "key": null,
1589
+ "type": 5,
1590
+ },
1591
+ ],
1592
+ Array [
1593
+ 8,
1594
+ Object {
1595
+ "children": Array [],
1596
+ "displayName": "Child",
1597
+ "id": 8,
1598
+ "key": "0",
1599
+ "type": 5,
1600
+ },
1601
+ ],
1602
+ Array [
1603
+ 9,
1604
+ Object {
1605
+ "children": Array [],
1606
+ "displayName": "Child",
1607
+ "id": 9,
1608
+ "key": null,
1609
+ "type": 8,
1610
+ },
1611
+ ],
1612
+ ],
1613
+ },
1614
+ ],
1615
+ "version": 5,
1616
+}
1617
`;
1618
1619
exports[`ProfilingCache should report every traced interaction: Interactions 1`] = `
@@ -1260,140 +1634,139 @@ Array [
1634
`;
1635
1636
exports[`ProfilingCache should report every traced interaction: imported data 1`] = `
1263
-"{
1264
- \\"version\\": 5,
1265
- \\"dataForRoots\\": [
1266
- {
1267
- \\"commitData\\": [
1268
- {
1269
- \\"duration\\": 11,
1270
- \\"fiberActualDurations\\": [
1271
- [
1637
+Object {
1638
+ "dataForRoots": Array [
1639
+ Object {
1640
+ "commitData": Array [
1641
+ Object {
1642
+ "duration": 11,
1643
+ "fiberActualDurations": Array [
1644
+ Array [
1645
1,
1273
- 11
1646
+ 11,
1647
],
1275
- [
1648
+ Array [
1649
2,
1277
- 11
1650
+ 11,
1651
],
1279
- [
1652
+ Array [
1653
3,
1281
- 0
1654
+ 0,
1655
],
1283
- [
1656
+ Array [
1657
4,
1285
- 1
1286
- ]
1658
+ 1,
1659
+ ],
1660
],
1288
- \\"fiberSelfDurations\\": [
1289
- [
1661
+ "fiberSelfDurations": Array [
1662
+ Array [
1663
1,
1291
- 0
1664
+ 0,
1665
],
1293
- [
1666
+ Array [
1667
2,
1295
- 10
1668
+ 10,
1669
],
1297
- [
1670
+ Array [
1671
3,
1299
- 0
1672
+ 0,
1673
],
1301
- [
1674
+ Array [
1675
4,
1303
- 1
1304
- ]
1676
+ 1,
1677
+ ],
1678
],
1306
- \\"interactionIDs\\": [
1307
- 0
1679
+ "interactionIDs": Array [
1680
+ 0,
1681
],
1309
- \\"priorityLevel\\": \\"Immediate\\",
1310
- \\"screenshot\\": null,
1311
- \\"timestamp\\": 11
1682
+ "priorityLevel": "Immediate",
1683
+ "screenshot": null,
1684
+ "timestamp": 11,
1685
},
1313
- {
1314
- \\"duration\\": 11,
1315
- \\"fiberActualDurations\\": [
1316
- [
1686
+ Object {
1687
+ "duration": 11,
1688
+ "fiberActualDurations": Array [
1689
+ Array [
1690
3,
1318
- 0
1691
+ 0,
1692
],
1320
- [
1693
+ Array [
1694
5,
1322
- 1
1695
+ 1,
1696
],
1324
- [
1697
+ Array [
1698
2,
1326
- 11
1699
+ 11,
1700
],
1328
- [
1701
+ Array [
1702
1,
1330
- 11
1331
- ]
1703
+ 11,
1704
+ ],
1705
],
1333
- \\"fiberSelfDurations\\": [
1334
- [
1706
+ "fiberSelfDurations": Array [
1707
+ Array [
1708
3,
1336
- 0
1709
+ 0,
1710
],
1338
- [
1711
+ Array [
1712
5,
1340
- 1
1713
+ 1,
1714
],
1342
- [
1715
+ Array [
1716
2,
1344
- 10
1717
+ 10,
1718
],
1346
- [
1719
+ Array [
1720
1,
1348
- 0
1349
- ]
1721
+ 0,
1722
+ ],
1723
],
1351
- \\"interactionIDs\\": [
1352
- 1
1724
+ "interactionIDs": Array [
1725
+ 1,
1726
],
1354
- \\"priorityLevel\\": \\"Immediate\\",
1355
- \\"screenshot\\": null,
1356
- \\"timestamp\\": 22
1357
- }
1727
+ "priorityLevel": "Immediate",
1728
+ "screenshot": null,
1729
+ "timestamp": 22,
1730
+ },
1731
],
1359
- \\"displayName\\": \\"Parent\\",
1360
- \\"initialTreeBaseDurations\\": [],
1361
- \\"interactionCommits\\": [
1362
- [
1732
+ "displayName": "Parent",
1733
+ "initialTreeBaseDurations": Array [],
1734
+ "interactionCommits": Array [
1735
+ Array [
1736
0,
1364
- [
1365
- 0
1366
- ]
1737
+ Array [
1738
+ 0,
1739
+ ],
1740
],
1368
- [
1741
+ Array [
1742
1,
1370
- [
1371
- 1
1372
- ]
1373
- ]
1743
+ Array [
1744
+ 1,
1745
+ ],
1746
+ ],
1747
],
1375
- \\"interactions\\": [
1376
- [
1748
+ "interactions": Array [
1749
+ Array [
1750
0,
1378
- {
1379
- \\"__count\\": 1,
1380
- \\"id\\": 0,
1381
- \\"name\\": \\"mount: one child\\",
1382
- \\"timestamp\\": 0
1383
- }
1751
+ Object {
1752
+ "__count": 1,
1753
+ "id": 0,
1754
+ "name": "mount: one child",
1755
+ "timestamp": 0,
1756
+ },
1757
+ ],
1758
+ Array [
1759
+ 1,
1760
+ Object {
1761
+ "__count": 0,
1762
+ "id": 1,
1763
+ "name": "update: two children",
1764
+ "timestamp": 11,
1765
+ },
1766
],
1385
- [
1386
- 1,
1387
- {
1388
- \\"__count\\": 0,
1389
- \\"id\\": 1,
1390
- \\"name\\": \\"update: two children\\",
1391
- \\"timestamp\\": 11
1392
- }
1393
- ]
1767
],
1395
- \\"operations\\": [
1396
- [
1768
+ "operations": Array [
1769
+ Array [
1770
1,
1771
1,
1772
15,
@@ -1449,9 +1822,9 @@ exports[`ProfilingCache should report every traced interaction: imported data 1`
1822
0,
1823
4,
1824
4,
1452
- 1000
1825
+ 1000,
1826
],
1454
- [
1827
+ Array [
1828
1,
1829
1,
1830
8,
@@ -1484,12 +1857,13 @@ exports[`ProfilingCache should report every traced interaction: imported data 1`
1857
4,
1858
4,
1859
1,
1487
- 12000
1488
- ]
1860
+ 12000,
1861
+ ],
1862
],
1490
- \\"rootID\\": 1,
1491
- \\"snapshots\\": []
1492
- }
1493
- ]
1494
-}"
1863
+ "rootID": 1,
1864
+ "snapshots": Array [],
1865
+ },
1866
+ ],
1867
+ "version": 5,
1868
+}
1869
`;
src/__tests__/profilingCache-test.js
+90
-102
@@ -29,7 +29,7 @@ describe('ProfilingCache', () => {
29
TestRenderer = utils.requireTestRenderer();
30
});
31
32
- it('should collect data for each root', async done => {
32
+ it('should collect data for each root (including ones added or mounted after profiling started)', () => {
33
const Parent = ({ count }) => {
34
Scheduler.advanceTime(10);
35
const children = new Array(count)
@@ -48,58 +48,72 @@ describe('ProfilingCache', () => {
48
};
49
const MemoizedChild = React.memo(Child);
50
51
- const container = document.createElement('div');
51
+ const containerA = document.createElement('div');
52
+ const containerB = document.createElement('div');
53
+ const containerC = document.createElement('div');
54
53
- utils.act(() => ReactDOM.render(<Parent count={2} />, container));
55
+ utils.act(() => ReactDOM.render(<Parent count={2} />, containerA));
56
+ utils.act(() => ReactDOM.render(<Parent count={1} />, containerB));
57
utils.act(() => store.profilerStore.startProfiling());
55
- utils.act(() => ReactDOM.render(<Parent count={3} />, container));
56
- utils.act(() => ReactDOM.render(<Parent count={1} />, container));
57
- utils.act(() => ReactDOM.render(<Parent count={0} />, container));
58
+ utils.act(() => ReactDOM.render(<Parent count={3} />, containerA));
59
+ utils.act(() => ReactDOM.render(<Parent count={1} />, containerC));
60
+ utils.act(() => ReactDOM.render(<Parent count={1} />, containerA));
61
+ utils.act(() => ReactDOM.unmountComponentAtNode(containerB));
62
+ utils.act(() => ReactDOM.render(<Parent count={0} />, containerA));
63
utils.act(() => store.profilerStore.stopProfiling());
64
60
- let profilingDataForRoot = null;
61
-
62
- // TODO (profarc) Add multi roots
65
+ let allProfilingDataForRoots = [];
66
64
- function Suspender({ previousProfilingDataForRoot, rootID }) {
65
- profilingDataForRoot = store.profilerStore.getDataForRoot(rootID);
67
+ function Validator({ previousProfilingDataForRoot, rootID }) {
68
+ const profilingDataForRoot = store.profilerStore.getDataForRoot(rootID);
69
if (previousProfilingDataForRoot != null) {
70
expect(profilingDataForRoot).toEqual(previousProfilingDataForRoot);
71
} else {
69
- expect(profilingDataForRoot).toMatchSnapshot('ProfilingSummary');
72
+ expect(profilingDataForRoot).toMatchSnapshot(
73
+ `Data for root ${profilingDataForRoot.displayName}`
74
+ );
75
}
76
+ allProfilingDataForRoots.push(profilingDataForRoot);
77
return null;
78
}
79
74
- const rootID = store.roots[0];
80
+ const dataForRoots =
81
+ store.profilerStore.profilingData !== null
82
+ ? store.profilerStore.profilingData.dataForRoots
83
+ : null;
84
76
- await utils.actAsync(() =>
77
- TestRenderer.create(
78
- <React.Suspense fallback={null}>
79
- <Suspender previousProfilingDataForRoot={null} rootID={rootID} />
80
- </React.Suspense>
81
- )
82
- );
85
+ expect(dataForRoots).not.toBeNull();
86
84
- expect(profilingDataForRoot).not.toBeNull();
87
+ if (dataForRoots !== null) {
88
+ dataForRoots.forEach(dataForRoot => {
89
+ utils.act(() =>
90
+ TestRenderer.create(
91
+ <Validator
92
+ previousProfilingDataForRoot={null}
93
+ rootID={dataForRoot.rootID}
94
+ />
95
+ )
96
+ );
97
+ });
98
+ }
99
86
- utils.exportImportHelper(bridge, store, rootID);
100
+ expect(allProfilingDataForRoots).toHaveLength(3);
101
88
- await utils.actAsync(() =>
89
- TestRenderer.create(
90
- <React.Suspense fallback={null}>
91
- <Suspender
102
+ utils.exportImportHelper(bridge, store);
103
+
104
+ allProfilingDataForRoots.forEach(profilingDataForRoot => {
105
+ utils.act(() =>
106
+ TestRenderer.create(
107
+ <Validator
108
previousProfilingDataForRoot={profilingDataForRoot}
93
- rootID={rootID}
109
+ rootID={profilingDataForRoot.rootID}
110
/>
95
- </React.Suspense>
96
- )
97
- );
98
-
99
- done();
111
+ )
112
+ );
113
+ });
114
});
115
102
- it('should collect data for each commit', async done => {
116
+ it('should collect data for each commit', () => {
117
const Parent = ({ count }) => {
118
Scheduler.advanceTime(10);
119
const children = new Array(count)
@@ -129,7 +143,7 @@ describe('ProfilingCache', () => {
143
144
const allCommitData = [];
145
132
- function Suspender({ commitIndex, previousCommitDetails, rootID }) {
146
+ function Validator({ commitIndex, previousCommitDetails, rootID }) {
147
const commitData = store.profilerStore.getCommitData(rootID, commitIndex);
148
if (previousCommitDetails != null) {
149
expect(commitData).toEqual(previousCommitDetails);
@@ -145,41 +159,35 @@ describe('ProfilingCache', () => {
159
const rootID = store.roots[0];
160
161
for (let commitIndex = 0; commitIndex < 4; commitIndex++) {
148
- await utils.actAsync(() => {
162
+ utils.act(() => {
163
TestRenderer.create(
150
- <React.Suspense fallback={null}>
151
- <Suspender
152
- commitIndex={commitIndex}
153
- previousCommitDetails={null}
154
- rootID={rootID}
155
- />
156
- </React.Suspense>
164
+ <Validator
165
+ commitIndex={commitIndex}
166
+ previousCommitDetails={null}
167
+ rootID={rootID}
168
+ />
169
);
170
});
171
}
172
173
expect(allCommitData).toHaveLength(4);
174
163
- utils.exportImportHelper(bridge, store, rootID);
175
+ utils.exportImportHelper(bridge, store);
176
177
for (let commitIndex = 0; commitIndex < 4; commitIndex++) {
166
- await utils.actAsync(() => {
178
+ utils.act(() => {
179
TestRenderer.create(
168
- <React.Suspense fallback={null}>
169
- <Suspender
170
- commitIndex={commitIndex}
171
- previousCommitDetails={allCommitData[commitIndex]}
172
- rootID={rootID}
173
- />
174
- </React.Suspense>
180
+ <Validator
181
+ commitIndex={commitIndex}
182
+ previousCommitDetails={allCommitData[commitIndex]}
183
+ rootID={rootID}
184
+ />
185
);
186
});
187
}
178
-
179
- done();
188
});
189
182
- it('should calculate a self duration based on actual children (not filtered children)', async done => {
190
+ it('should calculate a self duration based on actual children (not filtered children)', () => {
191
store.componentFilters = [utils.createDisplayNameFilter('^Parent$')];
192
193
const Grandparent = () => {
@@ -208,7 +216,7 @@ describe('ProfilingCache', () => {
216
217
let commitData = null;
218
211
- function Suspender({ commitIndex, rootID }) {
219
+ function Validator({ commitIndex, rootID }) {
220
commitData = store.profilerStore.getCommitData(rootID, commitIndex);
221
expect(commitData).toMatchSnapshot(
222
`CommitDetails with filtered self durations`
@@ -218,17 +226,11 @@ describe('ProfilingCache', () => {
226
227
const rootID = store.roots[0];
228
221
- await utils.actAsync(() => {
222
- TestRenderer.create(
223
- <React.Suspense fallback={null}>
224
- <Suspender commitIndex={0} rootID={rootID} />
225
- </React.Suspense>
226
- );
229
+ utils.act(() => {
230
+ TestRenderer.create(<Validator commitIndex={0} rootID={rootID} />);
231
});
232
233
expect(commitData).not.toBeNull();
230
-
231
- done();
234
});
235
236
it('should calculate self duration correctly for suspended views', async done => {
@@ -270,7 +272,7 @@ describe('ProfilingCache', () => {
272
273
const allCommitData = [];
274
273
- function Suspender({ commitIndex, rootID }) {
275
+ function Validator({ commitIndex, rootID }) {
276
const commitData = store.profilerStore.getCommitData(rootID, commitIndex);
277
allCommitData.push(commitData);
278
expect(commitData).toMatchSnapshot(
@@ -282,11 +284,9 @@ describe('ProfilingCache', () => {
284
const rootID = store.roots[0];
285
286
for (let commitIndex = 0; commitIndex < 2; commitIndex++) {
285
- await utils.actAsync(() => {
287
+ utils.act(() => {
288
TestRenderer.create(
287
- <React.Suspense fallback={null}>
288
- <Suspender commitIndex={commitIndex} rootID={rootID} />
289
- </React.Suspense>
289
+ <Validator commitIndex={commitIndex} rootID={rootID} />
290
);
291
});
292
}
@@ -296,7 +296,7 @@ describe('ProfilingCache', () => {
296
done();
297
});
298
299
- it('should collect data for each rendered fiber', async done => {
299
+ it('should collect data for each rendered fiber', () => {
300
const Parent = ({ count }) => {
301
Scheduler.advanceTime(10);
302
const children = new Array(count)
@@ -325,7 +325,7 @@ describe('ProfilingCache', () => {
325
326
const allFiberCommits = [];
327
328
- function Suspender({ fiberID, previousFiberCommits, rootID }) {
328
+ function Validator({ fiberID, previousFiberCommits, rootID }) {
329
const fiberCommits = store.profilerStore.profilingCache.getFiberCommits({
330
fiberID,
331
rootID,
@@ -344,49 +344,43 @@ describe('ProfilingCache', () => {
344
const rootID = store.roots[0];
345
346
for (let index = 0; index < store.numElements; index++) {
347
- await utils.actAsync(() => {
347
+ utils.act(() => {
348
const fiberID = store.getElementIDAtIndex(index);
349
if (fiberID == null) {
350
throw Error(`Unexpected null ID for element at index ${index}`);
351
}
352
TestRenderer.create(
353
- <React.Suspense fallback={null}>
354
- <Suspender
355
- fiberID={fiberID}
356
- previousFiberCommits={null}
357
- rootID={rootID}
358
- />
359
- </React.Suspense>
353
+ <Validator
354
+ fiberID={fiberID}
355
+ previousFiberCommits={null}
356
+ rootID={rootID}
357
+ />
358
);
359
});
360
}
361
362
expect(allFiberCommits).toHaveLength(store.numElements);
363
366
- utils.exportImportHelper(bridge, store, rootID);
364
+ utils.exportImportHelper(bridge, store);
365
366
for (let index = 0; index < store.numElements; index++) {
369
- await utils.actAsync(() => {
367
+ utils.act(() => {
368
const fiberID = store.getElementIDAtIndex(index);
369
if (fiberID == null) {
370
throw Error(`Unexpected null ID for element at index ${index}`);
371
}
372
TestRenderer.create(
375
- <React.Suspense fallback={null}>
376
- <Suspender
377
- fiberID={fiberID}
378
- previousFiberCommits={allFiberCommits[index]}
379
- rootID={rootID}
380
- />
381
- </React.Suspense>
373
+ <Validator
374
+ fiberID={fiberID}
375
+ previousFiberCommits={allFiberCommits[index]}
376
+ rootID={rootID}
377
+ />
378
);
379
});
380
}
385
-
386
- done();
381
});
382
389
- it('should report every traced interaction', async done => {
383
+ it('should report every traced interaction', () => {
384
const Parent = ({ count }) => {
385
Scheduler.advanceTime(10);
386
const children = new Array(count)
@@ -426,7 +420,7 @@ describe('ProfilingCache', () => {
420
421
let interactions = null;
422
429
- function Suspender({ previousInteractions, rootID }) {
423
+ function Validator({ previousInteractions, rootID }) {
424
interactions = store.profilerStore.profilingCache.getInteractionsChartData(
425
{
426
rootID,
@@ -442,26 +436,20 @@ describe('ProfilingCache', () => {
436
437
const rootID = store.roots[0];
438
445
- await utils.actAsync(() =>
439
+ utils.act(() =>
440
TestRenderer.create(
447
- <React.Suspense fallback={null}>
448
- <Suspender previousInteractions={null} rootID={rootID} />
449
- </React.Suspense>
441
+ <Validator previousInteractions={null} rootID={rootID} />
442
)
443
);
444
445
expect(interactions).not.toBeNull();
446
455
- utils.exportImportHelper(bridge, store, rootID);
447
+ utils.exportImportHelper(bridge, store);
448
457
- await utils.actAsync(() =>
449
+ utils.act(() =>
450
TestRenderer.create(
459
- <React.Suspense fallback={null}>
460
- <Suspender previousInteractions={interactions} rootID={rootID} />
461
- </React.Suspense>
451
+ <Validator previousInteractions={interactions} rootID={rootID} />
452
)
453
);
464
-
465
- done();
454
});
455
});
src/__tests__/profilingCharts-test.js
+21
-39
@@ -27,7 +27,7 @@ describe('profiling charts', () => {
27
});
28
29
describe('flamegraph chart', () => {
30
- it('should contain valid data', async done => {
30
+ it('should contain valid data', () => {
31
const Parent = ({ count }) => {
32
Scheduler.advanceTime(10);
33
return (
@@ -64,7 +64,7 @@ describe('profiling charts', () => {
64
65
let renderFinished = false;
66
67
- function Suspender({ commitIndex, rootID }) {
67
+ function Validator({ commitIndex, rootID }) {
68
const commitTree = store.profilerStore.profilingCache.getCommitTree({
69
commitIndex,
70
rootID,
@@ -89,27 +89,21 @@ describe('profiling charts', () => {
89
for (let commitIndex = 0; commitIndex < 2; commitIndex++) {
90
renderFinished = false;
91
92
- await utils.actAsync(
93
- () =>
94
- TestRenderer.create(
95
- <React.Suspense fallback={null}>
96
- <Suspender commitIndex={commitIndex} rootID={rootID} />
97
- </React.Suspense>
98
- ),
99
- 3
100
- );
92
+ utils.act(() => {
93
+ TestRenderer.create(
94
+ <Validator commitIndex={commitIndex} rootID={rootID} />
95
+ );
96
+ });
97
98
expect(renderFinished).toBe(true);
99
}
100
101
expect(renderFinished).toBe(true);
106
-
107
- done();
102
});
103
});
104
105
describe('ranked chart', () => {
112
- it('should contain valid data', async done => {
106
+ it('should contain valid data', () => {
107
const Parent = ({ count }) => {
108
Scheduler.advanceTime(10);
109
return (
@@ -146,7 +140,7 @@ describe('profiling charts', () => {
140
141
let renderFinished = false;
142
149
- function Suspender({ commitIndex, rootID }) {
143
+ function Validator({ commitIndex, rootID }) {
144
const commitTree = store.profilerStore.profilingCache.getCommitTree({
145
commitIndex,
146
rootID,
@@ -169,25 +163,19 @@ describe('profiling charts', () => {
163
for (let commitIndex = 0; commitIndex < 2; commitIndex++) {
164
renderFinished = false;
165
172
- await utils.actAsync(
173
- () =>
174
- TestRenderer.create(
175
- <React.Suspense fallback={null}>
176
- <Suspender commitIndex={commitIndex} rootID={rootID} />
177
- </React.Suspense>
178
- ),
179
- 3
180
- );
166
+ utils.act(() => {
167
+ TestRenderer.create(
168
+ <Validator commitIndex={commitIndex} rootID={rootID} />
169
+ );
170
+ });
171
172
expect(renderFinished).toBe(true);
173
}
184
-
185
- done();
174
});
175
});
176
177
describe('interactions', () => {
190
- it('should contain valid data', async done => {
178
+ it('should contain valid data', () => {
179
const Parent = ({ count }) => {
180
Scheduler.advanceTime(10);
181
return (
@@ -224,7 +212,7 @@ describe('profiling charts', () => {
212
213
let renderFinished = false;
214
227
- function Suspender({ commitIndex, rootID }) {
215
+ function Validator({ commitIndex, rootID }) {
216
const chartData = store.profilerStore.profilingCache.getInteractionsChartData(
217
{
218
rootID,
@@ -240,20 +228,14 @@ describe('profiling charts', () => {
228
for (let commitIndex = 0; commitIndex < 2; commitIndex++) {
229
renderFinished = false;
230
243
- await utils.actAsync(
244
- () =>
245
- TestRenderer.create(
246
- <React.Suspense fallback={null}>
247
- <Suspender commitIndex={commitIndex} rootID={rootID} />
248
- </React.Suspense>
249
- ),
250
- 3
251
- );
231
+ utils.act(() => {
232
+ TestRenderer.create(
233
+ <Validator commitIndex={commitIndex} rootID={rootID} />
234
+ );
235
+ });
236
237
expect(renderFinished).toBe(true);
238
}
255
-
256
- done();
239
});
240
});
241
});
src/__tests__/profilingCommitTreeBuilder-test.js
+7
-13
@@ -24,7 +24,7 @@ describe('commit tree', () => {
24
TestRenderer = utils.requireTestRenderer();
25
});
26
27
- it('should be able to rebuild the store tree for each commit', async done => {
27
+ it('should be able to rebuild the store tree for each commit', () => {
28
const Parent = ({ count }) => {
29
Scheduler.advanceTime(10);
30
return new Array(count)
@@ -47,7 +47,7 @@ describe('commit tree', () => {
47
48
let renderFinished = false;
49
50
- function Suspender({ commitIndex, rootID }) {
50
+ function Validator({ commitIndex, rootID }) {
51
const commitTree = store.profilerStore.profilingCache.getCommitTree({
52
commitIndex,
53
rootID,
@@ -62,19 +62,13 @@ describe('commit tree', () => {
62
for (let commitIndex = 0; commitIndex < 4; commitIndex++) {
63
renderFinished = false;
64
65
- await utils.actAsync(
66
- () =>
67
- TestRenderer.create(
68
- <React.Suspense fallback={null}>
69
- <Suspender commitIndex={commitIndex} rootID={rootID} />
70
- </React.Suspense>
71
- ),
72
- 3
73
- );
65
+ utils.act(() => {
66
+ TestRenderer.create(
67
+ <Validator commitIndex={commitIndex} rootID={rootID} />
68
+ );
69
+ });
70
71
expect(renderFinished).toBe(true);
72
}
77
-
78
- done();
73
});
74
});
src/__tests__/utils.js
+2
-6
@@ -133,11 +133,7 @@ export function requireTestRenderer(): ReactTestRenderer {
133
}
134
}
135
136
-export function exportImportHelper(
137
- bridge: Bridge,
138
- store: Store,
139
- rootID: number
140
-): void {
136
+export function exportImportHelper(bridge: Bridge, store: Store): void {
137
const { act } = require('./utils');
138
const {
139
prepareProfilingDataExport,
@@ -170,7 +166,7 @@ export function exportImportHelper(
166
expect(profilingDataFrontendInitial).toEqual(profilingDataFrontend);
167
168
// Snapshot the JSON-parsed object, rather than the raw string, because Jest formats the diff nicer.
173
- expect(serializedProfilingDataExport).toMatchSnapshot('imported data');
169
+ expect(parsedProfilingDataExport).toMatchSnapshot('imported data');
170
171
act(() => {
172
// Apply the new exported-then-reimported data so tests can re-run assertions.