angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng test does not run tests for all projects

Open swseverance opened this issue 3 years ago • 7 comments

🐞 Bug report

Command (mark with an x)

  • [ ] new
  • [ ] build
  • [ ] serve
  • [X] test
  • [ ] e2e
  • [ ] generate
  • [ ] add
  • [ ] update
  • [ ] lint
  • [ ] extract-i18n
  • [ ] run
  • [ ] config
  • [ ] help
  • [ ] version
  • [ ] doc

Is this a regression?

Don't know

Description

The ng test documentation states "When a project name is not supplied, it will execute for all projects". However, this does not appear to be true. Only the tests for a single project are run.

image

🔬 Minimal Reproduction

  1. Clone https://github.com/swseverance/my-workspace
  2. npm install
  3. Run ng test and observe how only the tests for the app are run. The tests for the lib are not run.

OR

  1. Create a workspace
  2. Create an app within the workspace
  3. Create a lib within the workspace
  4. Run ng test and observe how only the tests for the app are run. The tests for the lib are not run.

🔥 Exception or Error

N/A

🌍 Your Environment


Angular CLI: 11.2.14
Node: 14.17.0
OS: darwin x64

Angular: 11.2.14
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.14
@angular-devkit/build-angular   0.1102.14
@angular-devkit/core            11.2.14
@angular-devkit/schematics      11.2.14
@schematics/angular             11.2.14
@schematics/update              0.1102.14
ng-packagr                      11.2.4
rxjs                            6.6.7
typescript                      4.1.6

Anything else relevant?

swseverance avatar Jul 30 '21 15:07 swseverance

I think we should clarify the docs, that this only happens when test are not run in watch mode (Which is true by default).

alan-agius4 avatar Jul 30 '21 15:07 alan-agius4

The newly generated repository for #21619 reproduces this as well, but our upgraded v12 application does not.

TrevorKarjanis avatar Aug 20 '21 23:08 TrevorKarjanis

Interesting so something else might be going on

alan-agius4 avatar Aug 21 '21 06:08 alan-agius4

The newly generated repository for #21619 reproduces this as well, but our upgraded v12 application does not.

I stand to correct myself. The test command runs only the default project tests when a project is not provided and watch true by default. All tests are run when no project is provided and watch is false which we found useful for CI. Sorry for the confusion.

TrevorKarjanis avatar Oct 05 '21 16:10 TrevorKarjanis

So what is the solution to run all tests in monorepo?

Lonli-Lokli avatar Feb 22 '22 13:02 Lonli-Lokli

According to pr #21478 the documentation should clarify that all projects are only tested, when --watch=false. Will the content of that pr also be included in the angular docs or is this a different repository?

Anyway: angular.io does not yet show the modified documentation.

BePo65 avatar Jan 14 '23 16:01 BePo65

According to pr #21478 the documentation should clarify that all projects are only tested, when --watch=false. Will the content of that pr also be included in the angular docs or is this a different repository?

Anyway: angular.io does not yet show the modified documentation.

In #21478 it was decided it's not a purely documentation issue.

#26850 contains reproduction instructions with Angular 17 cli.

I wonder if the fix effort is tied with web-test-runner, since @dgp1130 wrote Moving Angular CLI to Jest and Web Test Runner, would you happen to know?

MattiJarvinen avatar Jan 12 '24 06:01 MattiJarvinen