Commit 21cfb47
committed
test(memoization): stabilize timestamp-refresh test under parallel load
The fake-timers + `advanceTimersByTimeAsync` combination was flaky
when the file ran concurrently with other suites — microtask
scheduling around `vi.useFakeTimers` is not deterministic under
Vitest's worker pool.
Replace with a `Date.now` spy plus a manual promise resolver. We
directly control virtual time (`fakeTime += 500`) and the fn's
completion point (`resolveFn!(2)`), so the regression assertion —
that the cache entry's timestamp gets refreshed on resolve, not
just on initial set — holds without any timer coordination.1 parent 4523738 commit 21cfb47
1 file changed
Lines changed: 23 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
284 | | - | |
285 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
286 | 289 | | |
287 | 290 | | |
| 291 | + | |
288 | 292 | | |
289 | 293 | | |
290 | | - | |
291 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
292 | 298 | | |
293 | 299 | | |
| 300 | + | |
294 | 301 | | |
295 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
296 | 305 | | |
297 | 306 | | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
302 | 311 | | |
303 | 312 | | |
304 | 313 | | |
305 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
306 | 318 | | |
307 | 319 | | |
308 | 320 | | |
| |||
0 commit comments