Angular 6 – NullInjectorError: No provider for HttpClient in unit tests
If you don’t import HttpClientModule (or HttpClientTestingModule) there, HttpClient won’t work because Angular doesn’t know about it. It doesn’t matter that you added HttpClientModule to, say, AppModule. It needs to be in TestBed.configureTestingModule.

import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import {HttpClientModule} from '@angular/common/http';

describe('myService', () => {
.
.
.
});
  1. How to Execute and Disable particular testgroup or testcase in jasmine?
    //Disable particular test group and case
    xDescribe -  @ignore testgroup
    xit - @ignore testcase
    
    //Enable particular test group and case
    fdescribe - Enable Particular Test Group
    fit - Enable Particular Test Case
    
  2. What is Arrange-Act-Assert Pattern
    • Arrange – Creating Object, Initilizing and Mocking Data
    • Act – Act on your unit testcase, execute necessary functionality and methods to be unit tested
    • Assert – Verifying code functionality is given output as expected
  3. What is difference between toBe vs toEqual?
    toBe compares value where as toEqual compares object.toEqual performs deep copy comparison.
  4. Difference between spyOn – returnValue and callFake?
    If we just want a return value when a service method is called then we can use any of and.callFake or and.returnValue. But incase if the service method takes
    some argument and the output of service method changes based on the argument, we use callFake with output logic in callback function. Though the same could be done
    using withargs in spyOn it requires redeclaring of multiple spyOn for multiple arguments.
  5. debugElement vs nativeElement
    NativeElement provides exactlty same API methods provided by Javascript for DOM Manipulation.So whatever methods was available while working in Javascript, the same methods would be available by using instance of nativeElement. debugElement, on the other hand, is a wrapper over native element with some additional methods. Using debugElement you could access rootElement which inturn calls nativeElement to get handle of DOM object. In otherwords debugElement is again going to call nativeElement to access the DOM objects. The additional advantage of using debugElement is accessing directive and component instance which is not possible in nativeElement.