Skip to content

test: disable vitest watch mode so nx test exits - #469

Merged
nightt5879 merged 1 commit into
developfrom
fix/vitest-watch-mode-hang
Sep 7, 2026
Merged

test: disable vitest watch mode so nx test exits#469
nightt5879 merged 1 commit into
developfrom
fix/vitest-watch-mode-hang

Conversation

@pubuzhixing8

Copy link
Copy Markdown
Contributor

Summary

nx run-many -t=test hangs instead of finishing. The @nx/vitest plugin generates a test target whose command is the bare vitest (not vitest run), and Nx 22 runs it through a pseudo-terminal. Vitest 4 sees an interactive TTY with no CI env var, so it defaults to watch mode: the suite passes, then the process sits there waiting for file changes and Nx reports Executing 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: false in the vitest config of all four projects that have tests:

  • apps/web/vite.config.ts
  • packages/drawnix/vite.config.ts
  • packages/react-board/vite.config.ts
  • packages/react-text/vite.config.ts

Watch mode is still available on demand via nx test <project> --watch.

Related Issue

N/A

Validation

  • Applicable checks pass: lint, format check, tests, and build
  • Relevant E2E and manual tests are complete or not applicable

Evidence:

Before — nx run-many -t=test never exits:

   →  Executing 1/1 remaining tasks...
   ⠴  nx run web:test
   ✔  3/3 succeeded [3 read from cache]

After — npx nx run-many -t=test --skip-nx-cache exits cleanly:

 Test Files  9 passed (9)      # packages/drawnix
      Tests  26 passed (26)

 Test Files  1 passed (1)      # apps/web
      Tests  1 passed (1)

 NX   Successfully ran target test for 4 projects

npm run lint and npm run format:check both pass.

AI Assistance

Did you use AI tools to generate or substantially modify code, tests, or documentation in this pull request?

  • No
  • Yes

If yes:

  • Tool/model: Claude Code / Opus 5

  • AI-assisted work: Root-cause analysis of the hanging test target, the watch: false change 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

  • The title and description are in English, and the change is focused
  • I reviewed and understand every submitted change
  • Tests, documentation, and translations were updated when needed

🤖 Generated with Claude Code

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>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying drawnix with  Cloudflare Pages  Cloudflare Pages

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

View logs

@nightt5879 nightt5879 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! The --watch option looks useful for local development.

@nightt5879
nightt5879 merged commit d0b048b into develop Sep 7, 2026
2 checks passed
@nightt5879
nightt5879 deleted the fix/vitest-watch-mode-hang branch September 7, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants