https://github.com/koka/vitest_pnpm_problem
Demo of automock problem in vitest when used on pnpm monorepo
https://github.com/koka/vitest_pnpm_problem
Last synced: 3 months ago
JSON representation
Demo of automock problem in vitest when used on pnpm monorepo
- Host: GitHub
- URL: https://github.com/koka/vitest_pnpm_problem
- Owner: Koka
- Created: 2025-03-20T10:59:26.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-03-20T13:19:09.000Z (3 months ago)
- Last Synced: 2025-03-20T14:30:49.146Z (3 months ago)
- Language: JavaScript
- Homepage: https://github.com/vitest-dev/vitest/issues/7708
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Automocking problem in pnpm monorepos
We've encountered a problem in our pnpm monorepo when __mocks__ folder automocking doen't work for packages that are imported from pnpm workspace rather than npm registry.
## Project setup
- packages/package_one - simple function exported, published to NPM as @koka58/package_one
- packages/package_two - imports packages/package_one from pnpm workspace and tries to mock it
- packages/package_three - imports packages/package_one from NPM registry and tries to mock it## Problem
When we run `pnpm test` it works fine for `package_three`, but not `package_two`, while the only difference between them is the way they import `package_one`
## Reproduction
Run `pnpm test` in the repo root, see tests for `package_two` failing
## StackBlitz env to try
https://stackblitz.com/~/github.com/Koka/vitest_pnpm_problem