https://github.com/levrik/vitest-circular-mock-issue
https://github.com/levrik/vitest-circular-mock-issue
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/levrik/vitest-circular-mock-issue
- Owner: levrik
- Created: 2026-04-21T06:32:56.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-21T06:48:42.000Z (about 2 months ago)
- Last Synced: 2026-04-21T08:35:51.801Z (about 2 months ago)
- Language: TypeScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Minimal repro: `vi.mock` broken by circular import + setup file
Single-package reproduction. No external dependencies beyond `vitest`.
## File structure
```
src/
core.ts ← imported by setup; optionally re-exports from ./feature (toggle)
feature/
index.ts ← re-exports api + process (what core points to circularly)
api.ts ← imports from ../core ← the module being mocked
process.ts ← imports getData from ./api ← the consumer
api.test.ts ← vi.mock('./api')
vitest/
setup.mts ← import { fetchAndProcess } '../src/core'
vitest.unit.config.ts
```
## Toggle
**`src/core.ts`** — comment/uncomment one line:
```ts
// Uncomment to reproduce:
// export { fetchAndProcess } from './feature/index';
```
Run: `npm run test`