vitest-5-0-0-4-b
Claude Code's read-only tools, web search on, ludion sync off
Question
I run vitest inside packages/foo and it ignores the root config. Is that expected?
Answer key
- A correct answer says
- Vitest 5 no longer searches parent directories for a config file.
- The stale answer
- Vitest walks up ancestor directories to find vitest.config / vite.config.
Answer
Yes, that's expected. Vitest, like Vite, only looks for `vitest.config.*` or `vite.config.*` in the directory you run it from (its root). It doesn't search parent directories, so running it inside `packages/foo` with no config there means it uses the defaults.
You can fix this in one of three ways:
- **Point at the root config:** run `vitest --config ../../vitest.config.ts`.
- **Add a config to the package:** create a small `packages/foo/vitest.config.ts` that imports the root config and extends it with `mergeConfig` from `vitest/config`.
- **Run from the repo root:** define the packages with `test.projects` (called "workspace" in older versions) in the root config, then run `vitest --project foo` from the root.Grade
correct
The judge's reason: It says Vitest does not search parent directories and only looks in the root, which matches the key and does not present the stale walk-up behavior.
Session log
Agent
Yes, that's expected. Vitest, like Vite, only looks for `vitest.config.*` or `vite.config.*` in the directory you run it from (its root). It doesn't search parent directories, so running it inside `packages/foo` with no config there means it uses the defaults. You can fix this in one of three ways: - **Point at the root config:** run `vitest --config ../../vitest.config.ts`. - **Add a config to the package:** create a small `packages/foo/vitest.config.ts` that imports the root config and extends it with `mergeConfig` from `vitest/config`. - **Run from the repo root:** define the packages with `test.projects` (called "workspace" in older versions) in the root config, then run `vitest --project foo` from the root.