Skip to main content
Version: 21

Testing

Testing is a crucial part of software development, especially for large applications, as it improves reliability and maintainability.

Testing frameworks

Do use a testing framework.

Why?

The Angular testing ecosystem has completed its transition. Karma and Jasmine have been replaced by Vitest as the recommended and default testing framework in Angular v21. While legacy projects may still use Karma/Jasmine, new projects should adopt Vitest for better performance and modern tooling.

Vitest offers a fast and efficient testing experience with support for both simulated and real browser environments. It is actively maintained, officially supported by Angular and integrated directly into the Angular CLI.

Why?

Karma has been the default test runner for Angular applications for many years. However, it has been deprecated in 2023 and is no longer maintained. Vitest replaced it as the default testing framework in Angular in v21, and Angular's support for Karma/Jasmine will drop in future releases.

You can still use Karma and Jasmine for existing projects, but you will most likely need to migrate to Vitest in the future to ensure compatibility with newer Angular versions. For new projects, you should directly start with Vitest.

Why?

Jest and Web Test Runner were evaluated as potential alternatives to Karma/Jasmine but were not chosen as the official recommendation. Experimental support for Jest and Web Test Runner is deprecated and will be removed in Angular v22.

End-to-end testing (e2e)

Consider e2e testing for critical user flows and complex interactions.

Do use an e2e testing tool.