How to use the Angular CLI test command line


Takes the name of the project, as specified in the projects section of the angular.json workspace configuration file. When a project name is not supplied, it will execute for all projects.

Set up testing
ng test
ng t
Compiling @angular/core/testing : es2015 as esm2015
Compiling @angular/platform-browser/testing : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/common/testing : es2015 as esm2015
Compiling @angular/router/testing : es2015 as esm2015
Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015
⠙ Generating browser application bundles (phase: building)...29 06 2021 10:02:41.970:WARN [karma]: No captured browser, open http://localhost:9876/
29 06 2021 10:02:41.980:INFO [karma-server]: Karma v6.1.2 server started at http://localhost:9876/
29 06 2021 10:02:41.981:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
29 06 2021 10:02:41.985:INFO [launcher]: Starting browser Chrome
✔ Browser application bundle generation complete.
29 06 2021 10:02:50.069:WARN [karma]: No captured browser, open http://localhost:9876/
✔ Browser application bundle generation complete.
29 06 2021 10:02:50.766:INFO [Chrome 91.0.4472.114 (Mac OS 10.15.7)]: Connected on socket EgxnYMBGYuRr9ebhAAAB with id 56954275
Chrome 91.0.4472.114 (Mac OS 10.15.7): Executed 3 of 3 SUCCESS (0.261 secs / 0.184 secs)

The Angular CLI test Help Commands and Options

  ng test <project> [options]
  ng t <project> [options]

The name of the project to build. Can be an application or a library.
Override which browsers tests are run against.
--code-coverage default:false
Output a code coverage report.
Globs to exclude from code coverage.
One or more named builder configurations as a comma-separated list as specified in the "configurations" section of angular.json. The builder uses the named configurations to run the given target. Setting this explicitly overrides the "--prod" flag. Aliases: -c
--help default:false
Shows a help message for this command in the console.
Globs of files to include, relative to workspace or project root. There are 2 special cases: when a path to directory is provided, all spec files ending "[email protected](ts|tsx)" will be included when a path to a file is provided, and a matching spec file exists it will be included instead
--inline-style-language default:css
The stylesheet language to use for the application's inline component styles.
The name of the Karma configuration file.
The name of the main entry-point file.
Enable and define the file watching poll time period in milliseconds.
The name of the polyfills file.
Do not use the real path when resolving modules. If unset then will default to true if NodeJS option --preserve-symlinks is set.
Deprecated: Use --configuration production instead. Shorthand for "--configuration=production". Set the build configuration to the production target. By default, the production target is set up in the workspace configuration such that all builds make use of bundling, limited tree-shaking, and also limited dead code elimination.
--progress default:true
Log progress to the console while building.
Karma reporters to use. Directly passed to the karma runner.
--source-map default:true
Output source maps for scripts and styles.
The name of the TypeScript configuration file.
Run build when files change.
TypeScript configuration for Web Worker modules.

Related Tags