This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
/
test-react.js
913 lines (741 loc) · 25.7 KB
/
test-react.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/* @flow */
let fs = require("fs");
let path = require("path");
let { prepackSources } = require("../lib/prepack-node.js");
let babel = require("babel-core");
let React = require("react");
let ReactDOM = require("react-dom");
let ReactDOMServer = require("react-dom/server");
let PropTypes = require("prop-types");
let ReactRelay = require("react-relay");
let ReactTestRenderer = require("react-test-renderer");
let { mergeAdacentJSONTextNodes } = require("../lib/utils/json.js");
/* eslint-disable no-undef */
let { expect, describe, it } = global;
function cxShim(...args) {
let classNames = [];
for (let arg of args) {
if (typeof arg === "string") {
classNames.push(arg);
} else if (typeof arg === "object" && arg !== null) {
let keys = Object.keys(arg);
for (let key of keys) {
if (arg[key]) {
classNames.push(key);
}
}
}
}
return classNames.join(" ");
}
// assign for tests that use the cx() global
global.cx = cxShim;
function getDataFile(directory, name) {
let reactTestRoot = path.join(__dirname, "../test/react/");
let data = fs.readFileSync(path.join(reactTestRoot, directory, name)).toString();
return data;
}
function MockURI(url) {
this.url = url;
}
MockURI.prototype.addQueryData = function() {
this.url += "&queryData";
return this;
};
MockURI.prototype.makeString = function() {
return this.url;
};
function runTestSuite(outputJsx, shouldTranspileSource) {
let errorsCaptured = [];
let reactTestRoot = path.join(__dirname, "../test/react/");
let prepackOptions = {
errorHandler: diag => {
errorsCaptured.push(diag);
if (diag.severity !== "Warning" && diag.severity !== "Information") {
return "Fail";
}
return "Recover";
},
compatibility: "fb-www",
internalDebug: true,
serialize: true,
uniqueSuffix: "",
maxStackDepth: 100,
reactEnabled: true,
reactOutput: outputJsx ? "jsx" : "create-element",
inlineExpressions: true,
invariantLevel: 0,
stripFlow: true,
};
let checkForReconcilerFatalError = false;
async function expectReconcilerFatalError(func) {
checkForReconcilerFatalError = true;
try {
await func();
} catch (e) {
expect(e.__isReconcilerFatalError).toBe(true);
expect(e.message).toMatchSnapshot();
} finally {
checkForReconcilerFatalError = false;
}
}
function compileSourceWithPrepack(source) {
let code = `(function(){${source}})()`;
let serialized;
errorsCaptured = [];
try {
serialized = prepackSources([{ filePath: "", fileContents: code, sourceMapContents: "" }], prepackOptions);
} catch (e) {
if (e.__isReconcilerFatalError && checkForReconcilerFatalError) {
throw e;
}
errorsCaptured.forEach(error => {
console.error(error);
});
throw e;
}
if (serialized == null || serialized.reactStatistics == null) {
throw new Error("React test runner failed during serialization");
}
return {
compiledSource: serialized.code,
statistics: serialized.reactStatistics,
};
}
function transpileSource(source) {
return babel.transform(source, {
presets: ["babel-preset-react"],
plugins: ["transform-object-rest-spread"],
}).code;
}
function runSource(source) {
let transformedSource = transpileSource(source);
/* eslint-disable no-new-func */
let fn = new Function("require", "module", transformedSource);
let moduleShim = { exports: null };
let requireShim = name => {
switch (name) {
case "React":
case "react":
return React;
case "react-dom":
case "ReactDOM":
return ReactDOM;
case "react-dom/server":
case "ReactDOMServer":
return ReactDOMServer;
case "PropTypes":
case "prop-types":
return PropTypes;
case "RelayModern":
return ReactRelay;
case "cx":
return cxShim;
case "FBEnvironment":
return {};
case "URI":
return MockURI;
default:
throw new Error(`Unrecognized import: "${name}".`);
}
};
try {
// $FlowFixMe flow doesn't new Function
fn(requireShim, moduleShim);
} catch (e) {
console.error(transformedSource);
throw e;
}
return moduleShim.exports;
}
async function runTest(directory, name, firstRenderOnly = false, data) {
let source = fs.readFileSync(path.join(reactTestRoot, directory, name)).toString();
if (shouldTranspileSource) {
source = transpileSource(source);
}
let { compiledSource, statistics } = compileSourceWithPrepack(source);
expect(statistics).toMatchSnapshot();
let A = runSource(source);
let B = runSource(compiledSource);
expect(typeof A).toBe(typeof B);
if (typeof A !== "function") {
// Test without exports just verifies that the file compiles.
return;
}
let config = {
createNodeMock(x) {
return x;
},
};
let rendererA = ReactTestRenderer.create(null, config);
let rendererB = ReactTestRenderer.create(null, config);
if (A == null || B == null) {
throw new Error("React test runner issue");
}
// Use the original version of the test in case transforming messes it up.
let { getTrials: getTrialsA, independent } = A;
let { getTrials: getTrialsB } = B;
// Run tests that assert the rendered output matches.
let resultA = getTrialsA(rendererA, A, data);
let resultB = independent ? getTrialsB(rendererB, B, data) : getTrialsA(rendererB, B, data);
// The test has returned many values for us to check
for (let i = 0; i < resultA.length; i++) {
let [nameA, valueA] = resultA[i];
let [nameB, valueB] = resultB[i];
if (typeof valueA === "string" && typeof valueB === "string") {
expect(valueA).toBe(valueB);
} else {
expect(mergeAdacentJSONTextNodes(valueB, firstRenderOnly)).toEqual(
mergeAdacentJSONTextNodes(valueA, firstRenderOnly)
);
}
expect(nameB).toEqual(nameA);
}
}
async function stubReactRelay(f) {
let oldReactRelay = ReactRelay;
ReactRelay = {
QueryRenderer(props) {
return props.render({ props: {}, error: null });
},
createFragmentContainer() {
return null;
},
graphql() {
return null;
},
};
try {
await f();
} finally {
ReactRelay = oldReactRelay;
}
}
// Jest tests
let originalConsoleError = global.console.error;
// we don't want React's errors printed, it's too much noise
let excludeErrorsContaining = [
"Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null",
"Consider adding an error boundary to your tree to customize error handling behavior.",
"Warning:",
];
global.console.error = function(...args) {
let text = args[0];
if (typeof text === "string") {
for (let excludeError of excludeErrorsContaining) {
if (text.indexOf(excludeError) !== -1) {
return;
}
}
}
originalConsoleError.apply(this, args);
};
describe(`Test React with ${shouldTranspileSource ? "create-element input" : "JSX input"}, ${
outputJsx ? "JSX output" : "create-element output"
}`, () => {
describe("Functional component folding", () => {
let directory = "functional-components";
it("Simple", async () => {
await runTest(directory, "simple.js");
});
it("Simple 2", async () => {
await runTest(directory, "simple-2.js");
});
it("Simple 3", async () => {
await runTest(directory, "simple-3.js");
});
it("Simple 4", async () => {
await runTest(directory, "simple-4.js");
});
it("Simple 5", async () => {
await runTest(directory, "simple-5.js");
});
it("Simple 6", async () => {
await runTest(directory, "simple-6.js");
});
it("Simple 7", async () => {
await runTest(directory, "simple-7.js");
});
it("Simple 8", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "simple-8.js");
});
});
it("Simple 9", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "simple-9.js");
});
});
it("Simple 10", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "simple-10.js");
});
});
it("Simple 11", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "simple-11.js");
});
});
it("Simple 12", async () => {
await runTest(directory, "simple-12.js");
});
// this should intentionally fail
it("Runtime error", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "runtime-error.js");
});
});
it("Simple 13", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "simple-13.js");
});
});
it("Simple 14", async () => {
await runTest(directory, "simple-14.js");
});
it("Simple 15", async () => {
await runTest(directory, "simple-15.js");
});
it("__reactCompilerDoNotOptimize", async () => {
await runTest(directory, "do-not-optimize.js");
});
it("Mutations - not-safe 1", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "not-safe.js");
});
});
it("Mutations - not-safe 2", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "not-safe2.js");
});
});
it("Mutations - safe 1", async () => {
await runTest(directory, "safe.js");
});
it("Mutations - safe 2", async () => {
await runTest(directory, "safe2.js");
});
it("Handle mapped arrays", async () => {
await runTest(directory, "array-map.js");
});
it("Handle mapped arrays 2", async () => {
await runTest(directory, "array-map2.js");
});
it("Simple fragments", async () => {
await runTest(directory, "simple-fragments.js");
});
it("Simple children", async () => {
await runTest(directory, "simple-children.js");
});
it("Simple with new expression", async () => {
await runTest(directory, "simple-with-new-expression.js");
});
it("Simple refs", async () => {
await runTest(directory, "simple-refs.js");
});
it("16.3 refs", async () => {
await runTest(directory, "refs.js");
});
it("16.3 refs 2", async () => {
await runTest(directory, "refs2.js");
});
it("16.3 refs 3", async () => {
await runTest(directory, "refs3.js");
});
it("Simple with abstract props", async () => {
await runTest(directory, "simple-with-abstract-props.js");
});
it("Simple with unary expressions", async () => {
await runTest(directory, "simple-with-unary.js");
});
it("Simple with multiple JSX spreads", async () => {
await runTest(directory, "simple-with-jsx-spread.js");
});
it("Simple with multiple JSX spreads #2", async () => {
await runTest(directory, "simple-with-jsx-spread2.js");
});
it("Simple with multiple JSX spreads #3", async () => {
await runTest(directory, "simple-with-jsx-spread3.js");
});
it("Simple with multiple JSX spreads #4", async () => {
await runTest(directory, "simple-with-jsx-spread4.js");
});
it("Simple with multiple JSX spreads #5", async () => {
await runTest(directory, "simple-with-jsx-spread5.js");
});
it("Simple with multiple JSX spreads #6", async () => {
await runTest(directory, "simple-with-jsx-spread6.js");
});
it("Simple with Object.assign", async () => {
await runTest(directory, "simple-assign.js");
});
it("Simple with Object.assign #2", async () => {
await runTest(directory, "simple-assign2.js");
});
it("Simple with Object.assign #3", async () => {
await runTest(directory, "simple-assign3.js");
});
it("Simple with Object.assign #4", async () => {
await runTest(directory, "simple-assign4.js");
});
it("Simple with Object.assign #5", async () => {
await runTest(directory, "simple-assign5.js");
});
it("Circular reference", async () => {
await runTest(directory, "circular-reference.js");
});
it("Conditional", async () => {
await runTest(directory, "conditional.js");
});
it("Key nesting", async () => {
await runTest(directory, "key-nesting.js");
});
it("Key nesting 2", async () => {
await runTest(directory, "key-nesting-2.js");
});
it("Key nesting 3", async () => {
await runTest(directory, "key-nesting-3.js");
});
it("Key change", async () => {
await runTest(directory, "key-change.js");
});
it("Delete element prop key", async () => {
await runTest(directory, "delete-element-prop-key.js");
});
it("Key change with fragments", async () => {
await runTest(directory, "key-change-fragments.js");
});
it("Key not changing with fragments", async () => {
await runTest(directory, "key-not-change-fragments.js");
});
it("Component type change", async () => {
await runTest(directory, "type-change.js");
});
it("Component type same", async () => {
await runTest(directory, "type-same.js");
});
it("Dynamic props", async () => {
await runTest(directory, "dynamic-props.js");
});
it("Dynamic context", async () => {
await runTest(directory, "dynamic-context.js");
});
it("React.cloneElement", async () => {
await runTest(directory, "clone-element.js");
});
it("Return text", async () => {
await runTest(directory, "return-text.js");
});
it("Render array twice", async () => {
await runTest(directory, "array-twice.js");
});
it("Render nested array children", async () => {
await runTest(directory, "nested-array-children.js");
});
it("Return undefined", async () => {
await runTest(directory, "return-undefined.js");
});
it("Null or undefined props", async () => {
await runTest(directory, "null-or-undefined-props.js");
});
it("Event handlers", async () => {
await runTest(directory, "event-handlers.js");
});
it("Class component as root", async () => {
await runTest(directory, "class-root.js");
});
it("Class component as root with multiple render methods", async () => {
await runTest(directory, "class-root-with-render-methods.js");
});
it("Class component as root with props", async () => {
await runTest(directory, "class-root-with-props.js");
});
it("Class component as root with state", async () => {
await runTest(directory, "class-root-with-state.js");
});
it("Class component as root with refs", async () => {
await runTest(directory, "class-root-with-refs.js");
});
it("Class component as root with instance variables", async () => {
await runTest(directory, "class-root-with-instance-vars.js");
});
it("Class component as root with instance variables #2", async () => {
await runTest(directory, "class-root-with-instance-vars-2.js");
});
it("Additional functions closure scope capturing", async () => {
await runTest(directory, "additional-function-regression.js");
});
it("Dynamic ReactElement type", async () => {
await runTest(directory, "dynamic-type.js");
});
it("Dynamic ReactElement type #2", async () => {
await runTest(directory, "dynamic-type2.js");
});
});
describe("Class component folding", () => {
let directory = "class-components";
it("Simple", async () => {
await runTest(directory, "simple.js");
});
it("Simple classes", async () => {
await runTest(directory, "simple-classes.js");
});
it("Simple classes #2", async () => {
await runTest(directory, "simple-classes-2.js");
});
it("Simple classes #3", async () => {
await runTest(directory, "simple-classes-3.js");
});
// awaiting PR on nested additional support #1626,
// issues is that both the parent and child additional
// function share the same variable, so the serializer
// incorrectly emits it in the MainGenerator scope
it.skip("Simple classes with Array.from", async () => {
await runTest(directory, "array-from.js");
});
// same issue as last test
it.skip("Simple classes with Array.from 2", async () => {
await runTest(directory, "array-from2.js");
});
it("Inheritance chaining", async () => {
await runTest(directory, "inheritance-chain.js");
});
it("Classes with state", async () => {
await runTest(directory, "classes-with-state.js");
});
it("Complex class components folding into functional root component", async () => {
await runTest(directory, "complex-class-into-functional-root.js");
});
it("Complex class components folding into functional root component #2", async () => {
await runTest(directory, "complex-class-into-functional-root2.js");
});
it("Complex class components folding into functional root component #3", async () => {
await runTest(directory, "complex-class-into-functional-root3.js");
});
it("Complex class components folding into functional root component #4", async () => {
await runTest(directory, "complex-class-into-functional-root4.js");
});
it("Complex class components folding into functional root component #5", async () => {
await runTest(directory, "complex-class-into-functional-root5.js");
});
});
describe("Factory class component folding", () => {
let directory = "factory-components";
it("Simple factory classes", async () => {
await runTest(directory, "simple.js");
});
it("Simple factory classes 2", async () => {
await runTest(directory, "simple2.js");
});
});
describe("Render props", () => {
let directory = "render-props";
it("Relay QueryRenderer", async () => {
await runTest(directory, "relay-query-renderer.js");
});
it("Relay QueryRenderer 2", async () => {
await runTest(directory, "relay-query-renderer2.js");
});
it("Relay QueryRenderer 3", async () => {
await runTest(directory, "relay-query-renderer3.js");
});
it("React Context", async () => {
await runTest(directory, "react-context.js");
});
it("React Context 2", async () => {
await runTest(directory, "react-context2.js");
});
it("React Context 3", async () => {
await runTest(directory, "react-context3.js");
});
it("React Context 4", async () => {
await runTest(directory, "react-context4.js");
});
it("React Context 5", async () => {
await runTest(directory, "react-context5.js");
});
it("React Context 6", async () => {
await runTest(directory, "react-context6.js");
});
});
describe("First render only", () => {
let directory = "first-render-only";
it("Simple", async () => {
await runTest(directory, "simple.js", true);
});
it("Simple #2", async () => {
await runTest(directory, "simple-2.js", true);
});
it("componentWillMount", async () => {
await runTest(directory, "will-mount.js", true);
});
it("getDerivedStateFromProps", async () => {
await runTest(directory, "get-derived-state-from-props.js", true);
});
it("getDerivedStateFromProps 2", async () => {
await runTest(directory, "get-derived-state-from-props2.js", true);
});
it("getDerivedStateFromProps 3", async () => {
await runTest(directory, "get-derived-state-from-props3.js", true);
});
it("getDerivedStateFromProps 4", async () => {
await runTest(directory, "get-derived-state-from-props4.js", true);
});
it("getDerivedStateFromProps 5", async () => {
await runTest(directory, "get-derived-state-from-props5.js", true);
});
it("React Context", async () => {
await runTest(directory, "react-context.js");
});
it("React Context 2", async () => {
await runTest(directory, "react-context2.js");
});
it("React Context 3", async () => {
await runTest(directory, "react-context3.js");
});
it("React Context 4", async () => {
await runTest(directory, "react-context4.js");
});
it("React Context 5", async () => {
await runTest(directory, "react-context5.js");
});
it.skip("Replace this in callbacks", async () => {
await runTest(directory, "replace-this-in-callbacks.js");
});
it("Replace this in callbacks 2", async () => {
await runTest(directory, "replace-this-in-callbacks2.js");
});
it("Replace this in callbacks 3", async () => {
await runTest(directory, "replace-this-in-callbacks3.js");
});
});
describe("fb-www mocks", () => {
let directory = "mocks";
it("fb-www", async () => {
await stubReactRelay(async () => {
await runTest(directory, "fb1.js");
});
});
it("fb-www 2", async () => {
await runTest(directory, "fb2.js");
});
it("fb-www 3", async () => {
await stubReactRelay(async () => {
await runTest(directory, "fb3.js");
});
});
it("fb-www 4", async () => {
await stubReactRelay(async () => {
await runTest(directory, "fb4.js");
});
});
it("fb-www 5", async () => {
await runTest(directory, "fb5.js");
});
it("fb-www 6", async () => {
await runTest(directory, "fb6.js");
});
it("fb-www 7", async () => {
await runTest(directory, "fb7.js");
});
it("fb-www 8", async () => {
await runTest(directory, "fb8.js");
});
it("fb-www 9", async () => {
await runTest(directory, "fb9.js");
});
it("fb-www 10", async () => {
await runTest(directory, "fb10.js");
});
it("fb-www 11", async () => {
await runTest(directory, "fb11.js");
});
it("fb-www 12", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "fb12.js");
});
});
it("fb-www 13", async () => {
await runTest(directory, "fb13.js");
});
it("fb-www 14", async () => {
await runTest(directory, "fb14.js");
});
it("fb-www 15", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "fb15.js");
});
});
it("fb-www 16", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "fb16.js");
});
});
it("fb-www 17", async () => {
await runTest(directory, "fb17.js");
});
// Test fails for two reasons:
// - "uri.foo" on abstract string does not exist
// - unused.bar() does not exist (even if in try/catch)
it("fb-www 18", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "fb18.js");
});
});
it("fb-www 19", async () => {
await expectReconcilerFatalError(async () => {
await runTest(directory, "fb19.js");
});
});
it("fb-www 20", async () => {
await runTest(directory, "fb20.js");
});
it("fb-www 21", async () => {
await runTest(directory, "fb21.js");
});
it("fb-www 22", async () => {
await runTest(directory, "fb22.js");
});
it("fb-www 23", async () => {
await runTest(directory, "fb23.js");
});
it("repl example", async () => {
await runTest(directory, "repl-example.js");
});
it("Hacker News app", async () => {
let data = JSON.parse(getDataFile(directory, "hacker-news.json"));
await runTest(directory, "hacker-news.js", false, data);
});
it("Function bind", async () => {
await runTest(directory, "function-bind.js");
});
});
describe("react-dom server rendering", () => {
let directory = "server-rendering";
it("Hacker News app", async () => {
let data = JSON.parse(getDataFile(directory, "hacker-news.json"));
await runTest(directory, "hacker-news.js", false, data);
});
});
describe("react-dom", () => {
let directory = "react-dom";
it("createPortal", async () => {
await runTest(directory, "create-portal.js", false);
});
});
});
}
// pre non-transpiled
runTestSuite(true, false);
runTestSuite(false, false);
// pre transpiled
runTestSuite(true, true);
runTestSuite(false, true);