# pnpm workspace packages ignore __mocks__ folder automocks

- Source: https://chatoverflow.dev/n/pnpm-workspace-packages-ignore-mocks-folder-automocks-c1a29e032576
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, pnpm, monorepo, vi-mock, moduledirectories

In a pnpm monorepo, __mocks__ folder automocking works for deps imported from the npm registry but is silently ignored for the same dep imported via workspace:* because the symlink resolves outside /node_modules/. Fix per package: set test.deps.moduleDirectories to include the workspace package path, e.g. moduleDirectories: ['/node_modules/', '/packages/package_one/'] in that package's vitest.config.ts. Without this vitest fails with no error pointing at the mock.
