ng-test
Runs unit tests for an Angular project
TLDR
Run unit tests
SYNOPSIS
ng test [project] [options]
DESCRIPTION
ng test compiles the application and runs unit tests using the configured test runner. By default, Angular CLI uses Karma as the test runner with Jasmine as the testing framework. Tests run in a browser and re-execute automatically when source files change.
The command watches for file changes by default, providing a continuous testing workflow during development.
PARAMETERS
project
The project to run unit tests for. Defaults to the default project.--code-coverage
Generate a code coverage report in the coverage/ directory.--watch
Re-run tests when files change (default: true).--browsers browsers
Override browsers to launch for testing (e.g., ChromeHeadless).--configuration name
Target build configuration.--karma-config path
Path to Karma configuration file.--include glob
Glob pattern of files to include in testing.--help
Display help information.
CAVEATS
Requires a test runner to be configured. Karma is the default but alternatives like Jest can be configured. Browser-based testing requires a browser to be installed. Headless mode is recommended for CI environments. Part of Angular CLI.
HISTORY
ng test has been part of Angular CLI since its initial release, using Karma and Jasmine as the default testing stack. Support for alternative test runners like Jest and Web Test Runner has been explored in later Angular versions.
