Commit 08d0a85
test: migrate to Vitest fake timers, remove @testing-library/user-event, and resolve act warnings (#3147)
* test(react/useSetAtom): replace 'userEvent' with 'fireEvent'
* test(react/useAtomValue): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText', and add fake timers
* test(react/provider): remove 'waitFor'
* test(react/optimization): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText', and remove 'waitFor'
* test(react/onmount): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText', add fake timer, and remove 'waitFor'
* test(react/items): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText', and remove 'waitFor'
* test(react/dependency): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText', add fake timer, and remove 'waitFor'
* test(react/vanilla-utils/atomFamily): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText', add fake timer, and remove 'waitFor'
* test(react/vanilla-utils/atomWithDefault): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText', add fake timer, and remove 'waitFor'
* test(react/vanilla-utils/atomWithReducer): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText'
* test(react/vanilla-utils/atomWithRefresh): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText', and add fake timer
* test(react/vanilla-utils/atomWithStorage): replace 'userEvent' with 'fireEvent', 'findByText' with 'getByText', remove 'waitFor', and add fake timer
* test(react/abortable): replace Promise resolver pattern with setTimeout delay, replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', remove 'waitFor', add fake timer, and wrap render and fireEvent calls in act
* test(react/async): replace Promise resolver pattern with setTimeout delay, replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', remove 'waitFor', add fake timer, and wrap render and fireEvent calls in act
* test(react/async2): replace Promise resolver pattern with setTimeout delay, replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', remove 'waitFor' and 'assert', add fake timer, wrap render and fireEvent calls in act, enable skipped test, add infinite loop verification with onMountCallCount, and add intermediate state checks for setSelf timing
* test(react/basic): migrate to Vitest fake timers, replace Promise resolver pattern with setTimeout delay, replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', remove 'waitFor', and add appropriate timer progression and act wrapping
* test(react/vanilla-utils/freezeAtom): replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', and remove unnecessary 'async' keywords
* test(react/vanilla-utils/selectAtom): replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', and remove unnecessary 'async' keywords
* test(react/vanilla-utils/splitAtom): replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', and remove unnecessary 'async' keywords
* test(react/utils/useAtomCallback): replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', remove 'waitFor', add fake timer, and remove unnecessary 'async' keywords
* test(react/utils/useHydrateAtoms): replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', and remove unnecessary 'async' keywords
* test(react/utils/useReducerAtom): replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', and remove unnecessary 'async' keywords
* test(react/utils/useResetAtom): replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', and remove unnecessary 'async' keywords
* test(vanilla/utils/atomWithLazy): remove unnecessary 'async' keywords
* test(vanilla/utils/loadable): replace Promise.resolve with setTimeout delay, add fake timer, and remove unnecessary await
* test(vanilla/utils/unwrap): replace Promise resolver pattern with setTimeout delay, replace Promise.resolve with setTimeout delay, add fake timer, remove unnecessary await, and remove unnecessary async keyword
* test(vanilla/dependency): replace Promise resolver pattern with setTimeout delay, replace 'Promise.resolve' with setTimeout delay, add fake timer, and replace 'expect(await promise)' with 'expect().resolves'
* test(vanilla/effect): replace 'Promise.resolve' with 'vi.advanceTimersByTimeAsync' and add fake timer
* test(vanilla/store): migrate to Vitest fake timers, remove unnecessary 'async' keywords, replace Promise resolver patterns with setTimeout delays, and remove 'assert' and 'waitFor' imports
* test(react/transition): replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', add fake timer, and change Promise resolver pattern to setTimeout delay pattern
* test(react/error): replace 'userEvent' with 'fireEvent', add loading assertions and delays to Suspense tests, and remove unnecessary 'async' keywords and timer advancements from sync error tests
* test(react/vanilla-utils/loadable): replace Promise resolver pattern with setTimeout delay, replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', add fake timer, and remove unnecessary 'async' keywords
* test(react/async2): remove unnecessary 'act' wrapping from 'render', 'fireEvent.click', and 'vi.advanceTimersByTimeAsync' calls
* test(react/dependency): add 'async' keyword and 'await' to 'act' call, and fix 'act' callback syntax
* test(react/abortable, async, dependency, error, onmount, transition): remove unnecessary await act from fireEvent and add loading assertions
* test(react/vanilla-utils/atomWithObservable): replace 'userEvent' with 'fireEvent', replace 'findByText' with 'getByText', add fake timer, remove 'shouldAdvanceTime' option, and remove unnecessary 'async' keywords
* test(react/vanilla-utils/atomFamily, atomWithStorage): remove unnecessary 'async' keywords and add missing loading assertions
* test(react): replace string Suspense fallback with JSX element
* test(react/abortable): wrap fireEvent.click with await act to resolve act warnings
* test(react/async): wrap fireEvent.click with await act to resolve act warnings
* test(react/vanilla-utils/atomWithStorage): wrap render and fireEvent.click with await act to resolve act warnings
* test(react/vanilla-utils/loadable): wrap render with await act to resolve act warnings
* test(react/async2): wrap fireEvent.click and timer advance with await act to resolve act warnings
* chore(*): remove '@testing-library/user-event'
* test(react): wrap render calls with StrictMode, use Fragment for timing-sensitive tests
* test(react/async2): reduce to single assertion in setSelf timing test
* test(react/async): fix setCountAtom to use Promise with setTimeout
* test(react/async2): restore infinite pending test with Promise<never>
* Update tests/react/async.test.tsx
* test(react/async2): remove unnecessary act wrapper from fireEvent calls
* test(react/async): fix multiple async atoms test with precise timer control
* test(vanilla/utils/unwrap): replace 'setTimeout' with fake timer in error recovery test
* test(react/error): revert read function to sync in async write function test
* test(react/dependency): restore intentional async keyword in activateAction
* test(react/dependency): remove setTimeout from asyncAtom to restore microtask delay
* test(react/dependency): add initial loading assertion for async dependencies test
* test(react/basic): replace FIXME with NOTE explaining no loading state
* Revert "test(react/dependency): remove setTimeout from asyncAtom to restore microtask delay"
This reverts commit 278abe2.
* test(react/dependency): add loading assertion and remove unnecessary timer advancement in bail test
* test(react/async2): restore intermediate assertions with 'expect.assertions(6)' in setSelf timing test
* test(react): simplify Suspense fallback from '<div>loading</div>' to 'loading'
* test(react/abortable): remove redundant 'abortedCount' assertion before unmount
* test(react/async): remove 'setTimeout' from immediately-resolving async atoms in useEffect tests
* Update tests/react/async.test.tsx
Co-authored-by: Daishi Kato <[email protected]>
* test(react/async): remove 'setTimeout' from 'asyncAtom' to restore microtask delay in 'useEffect' test
* test(react/async): replace 'Promise.resolve' with 'async/await' pattern in 'anotherAsyncAtom'
* test(react/async): remove 'setTimeout' delay in non-suspense async write test (#389)
* test(react/async): replace 'setTimeout' Promise with 'Promise.resolve' in override promise test (#430)
* test(react/async): remove 'setTimeout' from 'derivedAtom' in combine/set two promise atoms tests (#442)
* test(react/async): remove 'setTimeout' from immediately-resolving async atoms in derived atom test
* test(react/async2): restore intermediate assertions with 'expect.assertions(6)' in setSelf timing test
* test(react/async): remove unnecessary 'setTimeout' delay in dependency chaining test (#813)
* test(react/basic): remove unnecessary 'setTimeout' delay in time delayed derived atom test (#947)
* test(react/dependency): remove 'setTimeout' from immediately-resolving async atom in bail test (#877)
* test(react/dependency): replace 'setTimeout' with 'Promise.resolve' and add FIXME for 'loading' state (#2565)
* test(react/async): add comments explaining 1000ms delay for useEffect's write operation
* test(react/async): move 'setTimeout' inside condition to skip delay when disabled (#751)
* restore the test order
* test(react/useAtomValue): revert async atom to immediately resolve without 'setTimeout'
* test(vanilla/utils/{loadable,unwrap}): revert to 'Promise.resolve' and use 'advanceTimersByTimeAsync(0)'
* test(vanilla/utils/unwrap): remove unnecessary 'act' wrapper from vanilla store test
* test(vanilla/store): revert 'Promise.resolve' to 'setTimeout' to preserve macrotask behavior
* test(react/vanilla-utils/loadable): restore 10ms delay with fake timer for infinite loop test (#1481)
* chore: empty commit
---------
Co-authored-by: Daishi Kato <[email protected]>
Co-authored-by: daishi <[email protected]>1 parent 4afc31c commit 08d0a85
File tree
35 files changed
+2138
-2139
lines changed- tests
- react
- utils
- vanilla-utils
- vanilla
- utils
35 files changed
+2138
-2139
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
| 2 | + | |
| 3 | + | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
9 | | - | |
10 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
16 | | - | |
17 | 19 | | |
18 | 20 | | |
19 | | - | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | | - | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | | - | |
49 | | - | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
52 | 57 | | |
53 | | - | |
54 | | - | |
55 | 58 | | |
56 | 59 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
61 | 66 | | |
62 | 67 | | |
63 | 68 | | |
64 | | - | |
65 | | - | |
66 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
73 | | - | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
80 | | - | |
| 86 | + | |
81 | 87 | | |
82 | 88 | | |
83 | 89 | | |
| |||
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
99 | | - | |
| 105 | + | |
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
107 | | - | |
108 | | - | |
| 113 | + | |
| 114 | + | |
109 | 115 | | |
110 | | - | |
111 | | - | |
112 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
113 | 120 | | |
114 | 121 | | |
115 | 122 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
120 | 129 | | |
121 | 130 | | |
122 | 131 | | |
123 | | - | |
124 | | - | |
125 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
126 | 136 | | |
127 | 137 | | |
128 | 138 | | |
129 | 139 | | |
130 | 140 | | |
131 | 141 | | |
132 | 142 | | |
133 | | - | |
134 | 143 | | |
135 | 144 | | |
136 | | - | |
| 145 | + | |
137 | 146 | | |
138 | 147 | | |
139 | 148 | | |
| |||
157 | 166 | | |
158 | 167 | | |
159 | 168 | | |
160 | | - | |
| 169 | + | |
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
164 | 173 | | |
165 | 174 | | |
166 | 175 | | |
167 | | - | |
168 | | - | |
| 176 | + | |
| 177 | + | |
169 | 178 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
175 | 182 | | |
176 | | - | |
177 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
178 | 187 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 188 | + | |
183 | 189 | | |
184 | 190 | | |
185 | 191 | | |
186 | 192 | | |
187 | | - | |
188 | 193 | | |
189 | 194 | | |
190 | | - | |
| 195 | + | |
191 | 196 | | |
192 | 197 | | |
193 | 198 | | |
| |||
208 | 213 | | |
209 | 214 | | |
210 | 215 | | |
211 | | - | |
| 216 | + | |
212 | 217 | | |
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
216 | 221 | | |
217 | 222 | | |
218 | 223 | | |
219 | | - | |
220 | | - | |
| 224 | + | |
| 225 | + | |
221 | 226 | | |
222 | | - | |
| 227 | + | |
223 | 228 | | |
224 | | - | |
225 | | - | |
| 229 | + | |
| 230 | + | |
226 | 231 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
231 | 238 | | |
232 | | - | |
233 | | - | |
234 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
235 | 243 | | |
236 | 244 | | |
0 commit comments