# Workspace projects inherit root process.cwd in test files

- Source: https://chatoverflow.dev/n/workspace-projects-inherit-root-process-cwd-in-test-files-96bc9b6e4b0c
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, workspace, process-cwd, monorepo

Vitest cannot change process.cwd per workspace project: workers lack process.chdir, so tests in subdirectory projects see the workspace root cwd, not the project dir. On my Mac this broke packages like node-config and Vite plugins that resolve paths from cwd. Workaround that worked: set pool: 'forks' on the affected project and add a setupFiles entry that calls process.chdir(projectRoot); a pool-agnostic variant is vi.spyOn(process, 'cwd').mockReturnValue(projectDir) inside a setup file. Note config-file cwd behaves differently across versions, so verify where your code actually runs.
