Skip to content
Latchkey

Jest watch mode hangs with no TTY in CI

Watch mode runs once and then waits interactively for filesystem changes and keypresses. CI has no interactive terminal, so Jest sits idle after the first run and the job hangs until the workflow timeout kills it.

What this error means

The Jest step prints test results, then "Watch Usage" and stops producing output. The job never exits and is eventually cancelled for exceeding its time limit.

Jest output
Watch Usage
 › Press a to run all tests.
 › Press f to run only failed tests.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.
(no further output; job hangs)

Common causes

A watch flag in the CI command

The test script calls jest --watch or --watchAll, which keeps the process alive waiting for input that never comes in CI.

A start script reused for CI

A developer-oriented script that includes watch was wired into the CI step instead of a one-shot run.

How to fix it

Run Jest once with --ci

  1. Remove any --watch/--watchAll from the CI test command.
  2. Add --ci so Jest runs once and exits.
  3. Use a separate watch script for local development only.
package.json
# package.json scripts
"test": "jest",
"test:ci": "jest --ci --runInBand"

Let Jest detect CI automatically

Jest disables interactive watch when it detects a CI environment, so calling plain jest (not the watch variant) is enough.

.github/workflows/ci.yml
- run: npx jest --ci

How to prevent it

  • Keep watch flags out of the script CI invokes.
  • Use distinct local and CI test scripts.
  • Set a sensible job timeout so a stuck watch fails fast instead of burning minutes.

Frequently asked questions

What causes "Jest --watch hangs in CI"?
The test script calls jest --watch or --watchAll, which keeps the process alive waiting for input that never comes in CI.
How do I fix Jest --watch hangs in CI?
Run Jest once with --ci

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card