Angular unit testing building blocks
The following are some of the key building blocks to be used when writing unit tests for Angular apps:
TestBed
: This is the most important building block of Angular testing utilities.TestBed
is used to create an Angular testing module using theÂ@NgModule
class, which is configured using theÂconfigureTestingModule
 method. InvokingconfigureTestingModule
onTestBed
creates a testing environment for the component to be tested. Essentially, the component to be tested is detached from its own module and reattached to the Angular testing module. A metadata object declaring the components to be tested is passed to theÂconfigureTestingModule
 method.Â
After configuring the test environment, the next step is to create a component fixture, which is done by invoking the createComponent
API on TestBed
. Once the createComponent
API is invoked, TestBed
can't be configured any further.
Note that the configureTestingModule
and createComponent
methods are invoked within...