nx icon indicating copy to clipboard operation
nx copied to clipboard

Jest watch does not respond to key presses on Windows

Open GaryB432 opened this issue 1 year ago • 4 comments

Current Behavior

I have to Ctrl+C to Terminate batch job (Y/N) out of npx nx test my-proj --watch and cannot use any of the keys shown below, .

Running npx jest --watch in the project root works as expected, listing and responding to the keys shown below, e.g. Press a to run all tests or Press q to quit watch mode wlog.

Expected Behavior

npx nx test my-project --watch in a brand-new workspace should watch tests the same way npx jext --watch in the project root does.

GitHub Repo

No response

Steps to Reproduce

npx create-nx-workspace@latest ws -y --workspaceType=integrated --preset=apps --ci=skip
cd ws
npx nx g @nx/js:library --name=my-proj --directory=libs/my-proj --projectNameAndRootFormat=as-provided --unitTestRunner=jest --bundler=none
npx nx test my-proj --watch
# observe the jest watching options are not displayed
# project is being watched properly but the jest features are not working

This works as expected

cd .\libs\my-proj\
npx jest --watch
# observe watch usage and keypress handling
cd ../..

Nx Report

Node           : 20.17.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.8.2

nx                 : 19.7.3
@nx/js             : 19.7.3
@nx/jest           : 19.7.3
@nx/linter         : 19.7.3
@nx/eslint         : 19.7.3
@nx/workspace      : 19.7.3
@nx/devkit         : 19.7.3
@nx/eslint-plugin  : 19.7.3
@nrwl/tao          : 19.7.3
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • [ ] macOS
  • [ ] Linux
  • [X] Windows
  • [ ] Other (Please specify)

Additional Information

Watch Usage

Watch Usage
 › Press a to run all tests.
 › Press f to run only failed tests.
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press q to quit watch mode.
 › Press Enter to trigger a test run.

GaryB432 avatar Sep 13 '24 19:09 GaryB432

I have a similar issue where since upgrading to nx 19 from 17. Our symptoms are that we do not get the progress of the jest run in watch mode. We also don't get the "Watch Usage" commands printed out at the end of a run. It makes it hard to use jest in watch mode as you are unsure if Jest is actually running tests or not until the results of the spec files are printed to the console.

As mentioned above - jest behaves as it always has and displays progress / "Watch Usage" commands if I run it directly without nx via npx jest --watch

Node           : 20.9.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.8.1

nx                 : 19.6.5
@nx/js             : 19.6.5
@nx/jest           : 19.6.5
@nx/linter         : 19.6.5
@nx/eslint         : 19.6.5
@nx/workspace      : 19.6.5
@nx/angular        : 19.6.5
@nx/cypress        : 19.6.5
@nx/devkit         : 19.6.5
@nx/eslint-plugin  : 19.6.5
@nrwl/tao          : 19.6.5
@nx/web            : 19.6.5
@nx/webpack        : 19.6.5
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx-dotnet/core
---------------------------------------
Community plugins:
@ngrx/component-store               : 18.0.2
@ngrx/effects                       : 18.0.2
@ngrx/entity                        : 18.0.2
@ngrx/operators                     : 18.0.1
@ngrx/router-store                  : 18.0.2
@ngrx/schematics                    : 18.0.2
@ngrx/store                         : 18.0.2
@ngrx/store-devtools                : 18.0.2
@nx-dotnet/core                     : 2.1.0
@progress/kendo-angular-dateinputs  : 16.5.0
@progress/kendo-angular-dropdowns   : 16.5.0
@progress/kendo-angular-indicators  : 16.5.0
@progress/kendo-angular-intl        : 16.5.0
@progress/kendo-angular-l10n        : 16.5.0
@progress/kendo-angular-label       : 16.5.0
@progress/kendo-angular-popup       : 16.5.0
@progress/kendo-angular-progressbar : 16.5.0
@progress/kendo-angular-treeview    : 16.5.0
@progress/kendo-angular-upload      : 16.5.0
@testing-library/angular            : 15.1.0

paulcmason avatar Sep 30 '24 15:09 paulcmason

Hi - any news on this - it is a productivity killer! I have just updated to nx 20.2.2 and still see the same issue describe above. I have also run the steps listed by @GaryB432 above and still get the same results as him on 20.2.2. This is the nx report from @GaryB432's test above:

$ nx report

 NX   Report complete - copy this into the issue template

Node           : 22.12.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.8.1

nx                 : 20.2.2
@nx/js             : 20.2.2
@nx/jest           : 20.2.2
@nx/eslint         : 20.2.2
@nx/workspace      : 20.2.2
@nx/devkit         : 20.2.2
@nx/eslint-plugin  : 20.2.2
typescript         : 5.6.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

paulcmason avatar Dec 11 '24 15:12 paulcmason

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Jun 10 '25 00:06 github-actions[bot]

I can confirm that I am still experiencing this issue. Any updates?

paulcmason avatar Jun 10 '25 05:06 paulcmason