Commit 5bec739
committed
Upgrade tests to use react/jsx-runtime
Instead of createElement.
We should have done this when we initially released jsx-runtime but better
late than never. The general principle is that our tests should b
written using the most up-to-date idioms that we recommend for users,
except when explicitly testing an edge case or legacy behavior, like for
backwards compatibility.
Most of the diff is related to tweaking test output and isn't
very interesting.
I did have to workaround an issue related to component stacks. The
component stack logic depends on shared state that lives in the React
module. The problem is that most of our tests reset the React module
state and re-require a fresh instance of React, React DOM, etc.
However, the JSX runtime is not re-required because it's injected by
the compiler as a static import. This means its copy of the shared state
is no longer the same as the one used by React, causing any warning
logged by the JSX runtime to not include a component stack. (This same
issue also breaks string refs, but since we're removing those soon I'm
not so concerned about that.) The solution I went with for now is to
mock the JSX runtime with a proxy that re-requires the module on every
function invocation. I don't love this but it will have to do for now.
What we should really do is migrate our tests away from manually
resetting the module state and use import syntax instead.1 parent 4728548 commit 5bec739
File tree
18 files changed
+290
-72
lines changed- packages
- react-dom/src/__tests__
- react-reconciler/src/__tests__
- react-refresh/src/__tests__
- react-test-renderer/src/__tests__
- react/src/__tests__
- scripts/jest
- devtools
18 files changed
+290
-72
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
| 495 | + | |
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| |||
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
531 | | - | |
| 531 | + | |
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1007 | 1007 | | |
1008 | 1008 | | |
1009 | 1009 | | |
1010 | | - | |
| 1010 | + | |
1011 | 1011 | | |
1012 | 1012 | | |
1013 | 1013 | | |
| |||
1031 | 1031 | | |
1032 | 1032 | | |
1033 | 1033 | | |
1034 | | - | |
| 1034 | + | |
1035 | 1035 | | |
1036 | 1036 | | |
1037 | 1037 | | |
| |||
1049 | 1049 | | |
1050 | 1050 | | |
1051 | 1051 | | |
1052 | | - | |
| 1052 | + | |
1053 | 1053 | | |
1054 | 1054 | | |
1055 | 1055 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
114 | 117 | | |
115 | 118 | | |
116 | 119 | | |
117 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
118 | 124 | | |
119 | 125 | | |
120 | 126 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1244 | 1244 | | |
1245 | 1245 | | |
1246 | 1246 | | |
1247 | | - | |
| 1247 | + | |
1248 | 1248 | | |
1249 | | - | |
| 1249 | + | |
1250 | 1250 | | |
1251 | 1251 | | |
1252 | 1252 | | |
| |||
1295 | 1295 | | |
1296 | 1296 | | |
1297 | 1297 | | |
1298 | | - | |
| 1298 | + | |
1299 | 1299 | | |
1300 | | - | |
| 1300 | + | |
1301 | 1301 | | |
1302 | 1302 | | |
1303 | 1303 | | |
| |||
1317 | 1317 | | |
1318 | 1318 | | |
1319 | 1319 | | |
1320 | | - | |
| 1320 | + | |
1321 | 1321 | | |
1322 | 1322 | | |
1323 | 1323 | | |
| |||
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
96 | 105 | | |
97 | 106 | | |
98 | 107 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
292 | | - | |
| 291 | + | |
293 | 292 | | |
294 | 293 | | |
295 | 294 | | |
| |||
Lines changed: 24 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | | - | |
28 | | - | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
281 | | - | |
282 | 280 | | |
283 | 281 | | |
284 | 282 | | |
| |||
291 | 289 | | |
292 | 290 | | |
293 | 291 | | |
294 | | - | |
295 | | - | |
296 | 292 | | |
297 | 293 | | |
298 | 294 | | |
299 | 295 | | |
300 | 296 | | |
301 | 297 | | |
302 | | - | |
303 | | - | |
304 | 298 | | |
305 | 299 | | |
306 | 300 | | |
| |||
325 | 319 | | |
326 | 320 | | |
327 | 321 | | |
328 | | - | |
329 | | - | |
330 | 322 | | |
331 | 323 | | |
332 | 324 | | |
| |||
354 | 346 | | |
355 | 347 | | |
356 | 348 | | |
357 | | - | |
| 349 | + | |
358 | 350 | | |
359 | 351 | | |
360 | 352 | | |
| |||
374 | 366 | | |
375 | 367 | | |
376 | 368 | | |
377 | | - | |
| 369 | + | |
378 | 370 | | |
379 | 371 | | |
380 | 372 | | |
| |||
387 | 379 | | |
388 | 380 | | |
389 | 381 | | |
390 | | - | |
| 382 | + | |
391 | 383 | | |
392 | 384 | | |
393 | 385 | | |
| |||
405 | 397 | | |
406 | 398 | | |
407 | 399 | | |
408 | | - | |
| 400 | + | |
409 | 401 | | |
410 | 402 | | |
411 | 403 | | |
| |||
422 | 414 | | |
423 | 415 | | |
424 | 416 | | |
425 | | - | |
| 417 | + | |
426 | 418 | | |
427 | 419 | | |
428 | 420 | | |
429 | 421 | | |
430 | | - | |
| 422 | + | |
431 | 423 | | |
432 | 424 | | |
433 | 425 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
548 | 551 | | |
549 | 552 | | |
550 | 553 | | |
551 | | - | |
| 554 | + | |
552 | 555 | | |
553 | 556 | | |
554 | 557 | | |
| |||
0 commit comments