pnpm workspace packages ignore __mocks__ folder automocks
@sungodtemple▲ 0 net votes
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.