test: disable vitest watch mode so nx test exits - #469
Merged
Conversation
The `@nx/vitest` plugin generates a test target that runs the bare `vitest` command, and Nx 22 spawns it through a pseudo-terminal. Vitest sees a TTY with no CI env var, so it enters watch mode and never exits: `nx run-many -t=test` hangs on the first project that misses the cache. Set `watch: false` in every project's vitest config so test runs exit on their own locally and in CI. Use `nx test <project> --watch` when watch mode is actually wanted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Deploying drawnix with
|
| Latest commit: |
3a7ed09
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://720b8fa8.drawnix.pages.dev |
| Branch Preview URL: | https://fix-vitest-watch-mode-hang.drawnix.pages.dev |
nightt5879
approved these changes
Sep 7, 2026
nightt5879
left a comment
Member
There was a problem hiding this comment.
LGTM! The --watch option looks useful for local development.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nx run-many -t=testhangs instead of finishing. The@nx/vitestplugin generates a test target whose command is the barevitest(notvitest run), and Nx 22 runs it through a pseudo-terminal. Vitest 4 sees an interactive TTY with noCIenv var, so it defaults to watch mode: the suite passes, then the process sits there waiting for file changes and Nx reportsExecuting 1/1 remaining tasks...forever.This is easy to miss because cached projects are unaffected — only the first project that misses the cache hangs.
This PR sets
watch: falsein the vitest config of all four projects that have tests:apps/web/vite.config.tspackages/drawnix/vite.config.tspackages/react-board/vite.config.tspackages/react-text/vite.config.tsWatch mode is still available on demand via
nx test <project> --watch.Related Issue
N/A
Validation
Evidence:
Before —
nx run-many -t=testnever exits:After —
npx nx run-many -t=test --skip-nx-cacheexits cleanly:npm run lintandnpm run format:checkboth pass.AI Assistance
Did you use AI tools to generate or substantially modify code, tests, or documentation in this pull request?
If yes:
Tool/model: Claude Code / Opus 5
AI-assisted work: Root-cause analysis of the hanging test target, the
watch: falsechange in the four vite configs, and this description.My review and validation: Reviewed each config change and confirmed the full test run completes with the cache disabled.
I reviewed and understand the AI-assisted changes and can explain and maintain them
Checklist
🤖 Generated with Claude Code