Should we use Angular TestBed while unit testing? or is it reserved for E2E/Component testing?
Should we use Angular TestBed while unit testing? or is it reserved for E2E/Component testing?
The Angular docs says
You should write isolated unit tests for pipes and services.
Isolated unit tests do not require Testbed. (https://angular.io/guide/testing#isolated-unit-tests)
For Angular Components testing you would most likely want to use Testbed which I would still considered unit testing. Now saying this, I should quote the docs again by saying
Good developers write both kinds of tests for the same application part, often in the same spec file. Write simple isolated unit tests to validate the part in isolation. Write Angular tests to validate the part as it interacts with Angular, updates the DOM, and collaborates with the rest of the application.
I hope this helps.