How to use the Angular CLI test command line
Created
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) TOTAL: 3 SUCCESS
The Angular CLI test Help Commands and Options
Usage:
ng test <project> [options]
ng t <project> [options]
Arguments:
<project>The name of the project to build. Can be an application or a library.Options:
--browsersOverride which browsers tests are run against.--code-coverage default:falseOutput a code coverage report.--code-coverage-excludeGlobs to exclude from code coverage.--configurationOne 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:falseShows a help message for this command in the console.--includeGlobs 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 ".spec.@(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:cssThe stylesheet language to use for the application's inline component styles.--karma-configThe name of the Karma configuration file.--mainThe name of the main entry-point file.--pollEnable and define the file watching poll time period in milliseconds.--polyfillsThe name of the polyfills file.--preserve-symlinksDo not use the real path when resolving modules. If unset then will default to true if NodeJS option --preserve-symlinks is set.--prodDeprecated: 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:trueLog progress to the console while building.--reportersKarma reporters to use. Directly passed to the karma runner.--source-map default:trueOutput source maps for scripts and styles.--ts-configThe name of the TypeScript configuration file.--watchRun build when files change.--web-worker-ts-configTypeScript configuration for Web Worker modules.