Commit 3ff1540
authored
Prefer JSX in ReactNoop assertions (to combat out-of-memory test runs) (#26127)
## Summary
Prefer `getChildrenAsJSX` or `toMatchRenderedOutput` over `getChildren`.
Use `dangerouslyGetChildren` if you really need to (e.g. for `toBe`
assertions).
Prefer `getPendingChildrenAsJSX` over `getPendingChildren`. Use
`dangerouslyGetPendingChildren` if you really need to (e.g. for `toBe`
assertions).
`ReactNoop.getChildren` contains the fibers as non-enumerable
properties. If you pass the children to `toEqual` and have a mismatch,
Jest performance is very poor (to the point of causing out-of-memory
crashes e.g.
https://app.circleci.com/pipelines/github/facebook/react/38084/workflows/02ca0cbb-bab4-4c19-8d7d-ada814eeebb9/jobs/624297/parallel-runs/5?filterBy=ALL&invite=true#step-106-27).
Mismatches can sometimes be intended e.g. on gated tests.
Instead, I converted almost all of the `toEqual` assertions to
`toMatchRenderedOutput` assertions or compare the JSX instead. For
ReactNoopPersistent we still use `getChildren` since we have assertions
on referential equality. `toMatchRenderedOutput` is more accurate in
some instances anyway. I highlighted some of those more accurate
assertions in review-comments.
## How did you test this change?
- [x] `CIRCLE_NODE_TOTAL=20 CIRCLE_NODE_INDEX=5 yarn test
-r=experimental --env=development --ci`: Can take up to 350s (and use up
to 7GB of memory) on `main` but 11s on this branch
- [x] No more slow `yarn test` parallel runs of `yarn_test` jobs (the
steps in these runs should take <1min but sometimes they take 3min and
end with OOM like
https://app.circleci.com/pipelines/github/facebook/react/38084/workflows/02ca0cbb-bab4-4c19-8d7d-ada814eeebb9/jobs/624258/parallel-runs/5?filterBy=ALL:
Looks good with a sample size of 1
https://app.circleci.com/pipelines/github/facebook/react/38110/workflows/745109a2-b86b-429f-8c01-9b23a245417a/jobs/6246511 parent 78d2e9e commit 3ff1540
File tree
20 files changed
+1985
-1372
lines changed- packages
- react-noop-renderer/src
- react-reconciler/src/__tests__
20 files changed
+1985
-1372
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
789 | 789 | | |
790 | 790 | | |
791 | 791 | | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
792 | 811 | | |
793 | 812 | | |
794 | 813 | | |
795 | 814 | | |
796 | | - | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
797 | 821 | | |
798 | 822 | | |
799 | 823 | | |
| |||
Lines changed: 10 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | 108 | | |
113 | 109 | | |
114 | 110 | | |
| |||
127 | 123 | | |
128 | 124 | | |
129 | 125 | | |
130 | | - | |
| 126 | + | |
131 | 127 | | |
132 | 128 | | |
133 | 129 | | |
134 | | - | |
| 130 | + | |
135 | 131 | | |
136 | 132 | | |
137 | 133 | | |
138 | 134 | | |
139 | | - | |
| 135 | + | |
140 | 136 | | |
141 | 137 | | |
142 | 138 | | |
143 | 139 | | |
144 | | - | |
| 140 | + | |
145 | 141 | | |
146 | 142 | | |
147 | 143 | | |
| |||
181 | 177 | | |
182 | 178 | | |
183 | 179 | | |
184 | | - | |
| 180 | + | |
185 | 181 | | |
186 | 182 | | |
187 | 183 | | |
188 | 184 | | |
189 | 185 | | |
190 | | - | |
| 186 | + | |
191 | 187 | | |
192 | 188 | | |
193 | 189 | | |
194 | 190 | | |
195 | 191 | | |
196 | 192 | | |
197 | | - | |
| 193 | + | |
198 | 194 | | |
199 | 195 | | |
200 | 196 | | |
| |||
242 | 238 | | |
243 | 239 | | |
244 | 240 | | |
245 | | - | |
| 241 | + | |
246 | 242 | | |
247 | 243 | | |
248 | 244 | | |
249 | 245 | | |
250 | 246 | | |
251 | | - | |
| 247 | + | |
252 | 248 | | |
253 | 249 | | |
254 | 250 | | |
255 | 251 | | |
256 | 252 | | |
257 | 253 | | |
258 | | - | |
| 254 | + | |
259 | 255 | | |
260 | 256 | | |
261 | 257 | | |
| |||
0 commit comments