Commit 5137ffa
committed
fix: mock modules must not use cache:true on Node >=24.17
The 24.17/24.18 module-loader changes broke cache:true mock modules:
the mocked specifier exposes its export names with values never bound,
so ESM sources importing { Redis } from the mocked ioredis received
undefined (TypeError: Redis is not a constructor) — reproduced 1:1 in
docker node:24 (24.18.0) while node 24.16 still worked.
cache:false restores correct binding on every supported version
(verified on 22.23.1, 24.16.0 and 24.18.0 — 249/249 each). Instance
caching was not load-bearing for these mocks: all shared state lives
on the exported references themselves (RedisClientMock statics), so
each re-evaluation serves the same objects.1 parent 31d7dcf commit 5137ffa
1 file changed
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
50 | | - | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
0 commit comments