Commit dea2136
LogBoxData test migrated to Jest modern timers (#55757)
Summary:
This PR migrates the LogBoxData tests so that it uses Jest modern timers.
I removed the `legacyFakeTimers` property from `useFakeTimers` (like I did in the previous PR for Pressability tests #55410), and moved it to a `beforeEach`. This in combination with restoring real timers in `afterEach` improves tests reliability and isolation.
Then I modified some tests that started to fail by adding explicit `flushToObservers()`.
The extra flushToObservers() calls are necessary because addLog/addException schedule processing using `setImmediate`, and inside that callback `handleUpdate()` schedules observer notifications using another `setImmediate` (so we need to flush twice to simulate the correct behaviour like it was already done in some other tests in the test suite).
## Changelog:
[GENERAL] [CHANGED] - Migrated LogBoxData tests to Jest modern timers
Pull Request resolved: #55757
Test Plan:
- Ran LogBoxData-test and verify all tests cases passed
- Ran the React Native test suite to ensure all tests pass
- Verified test correctness by intentionally breaking production code after fixing the tests (eg. removing the `handleUpdate` call in `addException`, that changes the call to the `observer`)
Reviewed By: fabriziocucci
Differential Revision: D94903193
Pulled By: cortinico
fbshipit-source-id: caf497b77610c701849ceab5068e54589684d2ab1 parent 422770d commit dea2136
File tree
1 file changed
+17
-7
lines changed- packages/react-native/Libraries/LogBox/Data/__tests__
1 file changed
+17
-7
lines changedLines changed: 17 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | 13 | | |
17 | 14 | | |
18 | 15 | | |
| |||
144 | 141 | | |
145 | 142 | | |
146 | 143 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | 144 | | |
152 | 145 | | |
153 | 146 | | |
154 | 147 | | |
155 | 148 | | |
156 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
157 | 155 | | |
158 | 156 | | |
159 | 157 | | |
| |||
590 | 588 | | |
591 | 589 | | |
592 | 590 | | |
| 591 | + | |
593 | 592 | | |
| 593 | + | |
594 | 594 | | |
| 595 | + | |
595 | 596 | | |
| 597 | + | |
596 | 598 | | |
597 | 599 | | |
598 | 600 | | |
| |||
610 | 612 | | |
611 | 613 | | |
612 | 614 | | |
| 615 | + | |
613 | 616 | | |
| 617 | + | |
614 | 618 | | |
| 619 | + | |
615 | 620 | | |
| 621 | + | |
616 | 622 | | |
617 | 623 | | |
618 | 624 | | |
| |||
854 | 860 | | |
855 | 861 | | |
856 | 862 | | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
857 | 867 | | |
0 commit comments