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.
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
- Remove any
--watch/--watchAllfrom the CI test command. - Add
--ciso Jest runs once and exits. - Use a separate watch script for local development only.
# 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.
- run: npx jest --ciHow 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.