Commit cae8d3a
committed
fix(tests/cover): mock spawn via src/ relative path so threaded-pool dedup catches the prod instance
Both cover/type.test.mts and cover/code.test.mts used:
vi.mock('@socketsecurity/lib/process/spawn/child')
That mock keys on the package-specifier resolution. Inside the
production source (src/cover/type.ts, src/cover/code.ts), the
import is relative:
import { spawn } from '../process/spawn/child'
Under vitest's threaded pool, the two resolution paths land on
different module instances despite the alias collapsing them to
the same file. The mock applies to the package-path instance; the
production code uses the relative-path instance — uncoupled.
Fix matches the canonical pattern from
test/unit/releases/*.test.mts: mock via the src/ relative path so
both sides resolve to the same key in vitest's mock registry.
cover/type.test.mts: 4 previously-failing tests now pass (10/10).
cover/code.test.mts: 1 previously-failing test now passes (29/29).1 parent 4f933e2 commit cae8d3a
2 files changed
Lines changed: 16 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | | - | |
20 | | - | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
0 commit comments