Forrest logo
back to the ng tool

ng:tldr:45d5d

ng: Run unit tests.
$ ng test
try on your machine

The command "ng test" is used in Angular projects to run the unit tests that have been written for the application.

When executed, this command starts the Karma test runner, which is the default test runner for Angular applications. Karma launches a web server and opens a browser window, where it runs the tests in real browsers or headless browsers.

The "ng test" command looks for test files in the "src" directory of the project. These test files typically have a ".spec.ts" extension and are located next to the components, services, or other modules that they test.

By running "ng test", the application's unit tests are executed, and their results are displayed in the console. The test runner provides information about how many tests have passed or failed, as well as any errors or warnings encountered during the test run.

Running unit tests using "ng test" is an essential part of the development process in Angular, as it helps ensure that individual components and modules are functioning correctly. It is recommended to run tests regularly, especially after making changes to the codebase, to catch any potential issues early on and maintain the quality of the application.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ng tool