nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.82k stars 2.38k forks source link

Jest watch does not respond to key presses on Windows #27914

Open GaryB432 opened 2 months ago

GaryB432 commented 2 months ago

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

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.
paulcmason commented 2 months ago

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