Answers for "NullInjectorError: R3InjectorError(DynamicTestModule)[TaskService -> HttpClient -> HttpClient]: NullInjectorError: No provider for HttpClient!"

0

NullInjectorError: R3InjectorError(DynamicTestModule)[TaskService -> HttpClient -> HttpClient]: NullInjectorError: No provider for HttpClient!

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


describe('myService', () => {

      beforeEach(() => TestBed.configureTestingModule({
        imports: [HttpClientTestingModule], 
        providers: [myService]
      }));

       it('should be created', () => {
        const service: myService = TestBed.get(myService);
        expect(service).toBeTruthy();
       });

       it('should have getData function', () => {
        const service: myService = TestBed.get(myService);
        expect(service.getData).toBeTruthy();
       });

    });
Posted by: Guest on June-15-2021

Code answers related to "NullInjectorError: R3InjectorError(DynamicTestModule)[TaskService -> HttpClient -> HttpClient]: NullInjectorError: No provider for HttpClient!"

Browse Popular Code Answers by Language