Generating a component via Angular CLI creates a .spec file. Should integration and individual tests be included there?

Note that the spec file is actually optional. But in any case, you typically wouldn't want your integration tests combined with your unit tests no matter how you define the seams in your application. That's because they typically run for different reasons, at different times, in different environments. That being said, the only difference between them might be injecting a mock verses using a concrete implementation.

How can I tell if a test is individual or not.

This, and the rest of your questions, depend on where you fall on the testing-purist spectrum and how you relate that to your development reality. For example, Roy Osherove defines a "unit" as:

[a] "unit of work" or a "use case" inside the system.

That implies some amount of integration for any reasonably designed, non-trivial application. One thing's for sure though: if your test relies on a db connection, network availability, API/Service, file system, or any other volatile dependency, it's definitely an integration test.

Answer from ChiefTwoPencils on Stack Overflow
๐ŸŒ
Medium
ioanapana.medium.com โ€บ the-complete-guide-to-testing-in-angular-unit-testing-integration-testing-and-e2e-testing-2f03d4f467bd
The Complete Guide to Testing in Angular: Unit Testing, Integration Testing, and E2E Testing | by Ioana Pana | Medium
May 25, 2023 - Integration tests involve testing interactions between parts of your system. In an Angular context, this often means testing the interaction between a component and a service, or between a parent component and its child components.
Top answer
1 of 2
3

Generating a component via Angular CLI creates a .spec file. Should integration and individual tests be included there?

Note that the spec file is actually optional. But in any case, you typically wouldn't want your integration tests combined with your unit tests no matter how you define the seams in your application. That's because they typically run for different reasons, at different times, in different environments. That being said, the only difference between them might be injecting a mock verses using a concrete implementation.

How can I tell if a test is individual or not.

This, and the rest of your questions, depend on where you fall on the testing-purist spectrum and how you relate that to your development reality. For example, Roy Osherove defines a "unit" as:

[a] "unit of work" or a "use case" inside the system.

That implies some amount of integration for any reasonably designed, non-trivial application. One thing's for sure though: if your test relies on a db connection, network availability, API/Service, file system, or any other volatile dependency, it's definitely an integration test.

2 of 2
1

The standard practice is to put your individual unit tests in the jasmine spec files side-by-side with your components, directives, services. By default the cli will create these using jasmine and they will be run using the karma test runner.

For integration tests, create these in the e2e folder. These will again use jasmine by default, as well as the Protractor test runner. For the integration tests it is recommended you abstrac out much of the page interactions with page-objects, to keep your tests readable and at a high abstraction level.

Clarification

An integration test will test the integration of your Angular app with other layers such as a Rest or GraphQL backend. If you are looking to test the integration of components within the angular application, this would be a "deep unit" as long as it does not require any fixtures outside of the frontend app. If this deep unit test is what you are looking for, place these in spec files and run with your unit tests.

๐ŸŒ
Angular
v17.angular.io โ€บ guide โ€บ testing
Testing Guide
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
๐ŸŒ
Angular
angular.dev โ€บ guide โ€บ testing
Testing โ€ข Overview โ€ข Angular
You can also unit test an Angular application with other testing libraries and test runners. Each library and runner has its own installation procedures, configuration, and syntax. A robust test suite is a key part of a continuous integration (CI) pipeline.
๐ŸŒ
Testim
testim.io โ€บ blog โ€บ angular-integration-testing
Angular Integration Testing: A Practical, Introductory How-To - Testim Blog
November 11, 2020 - Angular integration testing is just as important as unit testing and end-to-end (E2E) testing. Using Angular integration testing, you can test two or more units of an Angular app that work together to perform a specific task.
๐ŸŒ
Medium
medium.com โ€บ ngconf โ€บ angular-testing-integration-testing-36a108efc39
Angular Testing: Integration Testing | by Quantarius Ray | ngconf | Medium
January 19, 2023 - But most importantly, โ€œto integrate something is to unit several pieces into a single functioning piece.โ€ In the Angular sense, this would be the complete view of a particular page in our application.
๐ŸŒ
Peerbits
peerbits.com โ€บ blog โ€บ complete-guide-to-testing-angular-apps.html
Testing Angular apps: A complete guide for developers
Learn unit testing, integration, and end-to-end testing for Angular apps using Jasmine, Karma, TestBed, Cypress & Protractor tools from skilled Angular expert.
๐ŸŒ
DEV Community
dev.to โ€บ bndf1 โ€บ modern-testing-practices-in-angular-from-unit-to-integration-testing-2c01
Modern Testing Practices in Angular: From Unit to Integration Testing - DEV Community
December 16, 2024 - Integration Tests: Broader in scope, these tests cover multiple components and services working together. They aim to verify that different parts of the application interact correctly, without mocking as many dependencies as unit tests.
Find elsewhere
๐ŸŒ
Infinum
infinum.com โ€บ handbook โ€บ frontend โ€บ angular โ€บ angular-guidelines-and-best-practices โ€บ testing
Frontend Handbook | Angular / Angular guidelines and best practices / Testing
In Angular, there is no special way of doing integration testing. There is a thin line between unit and integration tests, and that line is more conceptual than technical.
๐ŸŒ
Medium
medium.com โ€บ @relinns_technologies_pvt_ltd โ€บ angular-unit-testing-and-integration-testing-complete-guide-with-examples-2025-98dcf2aabe7b
Angular Unit Testing and Integration Testing: Complete Guide with Examples | by Relinns Technologies | Medium
August 13, 2025 - Core principles of Angular unit testing for isolated components, services, and pipes. Scope and strategy of integration testing in Angular for multi-part functionality.
๐ŸŒ
Testing-angular
testing-angular.com
Testing Angular โ€“ A Guide to Robust Angular Applications.
Unit, integration and end-to-end tests for Angular web applications. Free online book and e-book.
๐ŸŒ
Testing-angular
testing-angular.com โ€บ testing-principles
Testing principles โ€“ Testing Angular
February 17, 2021 - Dependencies are replaced with fakes. An integration test spans one Component together with its children and possibly connected Services as well. It is also possible to write a test that integrates all parts of an Angular Module.
๐ŸŒ
DEV Community
dev.to โ€บ kayis โ€บ isolated-unit-testing-and-deep-integration-testing-in-angular-19lg
Isolated unit testing and deep integration testing in Angular - DEV Community
November 8, 2019 - For testing, Angular provides TestBed, which can be used to create a TestModule that emulates Angular's @NgModule. In this section, we will be performing an integration test on our component by mocking an observable with an expected type of data.
๐ŸŒ
Angular
v20.angular.dev โ€บ guide โ€บ testing โ€บ unit-tests
Experimental unit testing integration โ€ข Angular
The Angular CLI provides an experimental unit test system that can use Vitest as a test runner.
๐ŸŒ
Testim
testim.io โ€บ blog โ€บ angular-testing-tutorial
Angular Testing Tutorial: What You Need and How to Start
June 16, 2025 - So far in this Angular testing ... the way to the data source. Integration tests technically can refer to any test that covers more than one unit....
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 77681760 โ€บ angular-integration-test-testing-api
Angular Integration Test - Testing APi - Stack Overflow
In angular, integration testing is more about testing if your component is integrating well with other components : this is different from unit testing, where you isolate your component and mock all of its dependencies.
๐ŸŒ
Medium
medium.com โ€บ @ana.dvorkina โ€บ unit-and-integration-tests-for-angular-components-323a2c681972
Unit and Integration tests for Angular components. Part 1 out of 3. | by Anastasia Dvorkina | Medium
May 17, 2018 - integration tests: checking that multiples units are interacting with each other correctly ยท Unit tests for Angular components can be split into 2 categories:
๐ŸŒ
30DaysCoding
blogs.30dayscoding.com โ€บ blogs โ€บ angular โ€บ testing-and-debugging โ€บ testing-angular-applications โ€บ integration-testing
Integration Testing
To perform integration tests, we need to set up a test bed that resembles the environment in which our application runs. This involves configuring the necessary dependencies and providers. Now itโ€™s time to write the actual test cases using Jasmine, the testing framework for Angular.
๐ŸŒ
GitHub
github.com โ€บ topics โ€บ angular-integration-testing
angular-integration-testing ยท GitHub Topics ยท GitHub
Learn to write Unit Testing and Integration Testing of Angular application for multiple types of components, directives, dependencies, routers and services.