I'm using jasmine as a test framework and karma as a test runner. I'm trying to create an HttpClient object so I could create a service that as a depedency to this object:
TestBed.configureTestingModule({ declarations: [HttpClient], imports: [HttpClient], providers: [HttpClient] }); TestBed.get(HttpClient);
But I'm getting the following error:
Error: Unexpected value 'HttpClient' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation.
Any one have an idea how to solve this?
Follows all the code:
import { I18nService } from "../../services/i18n.service"; import { TestBed, inject, async } from "@angular/core/testing"; import { EditionHistoryEventsModel } from "./dropdown.edition.history.events.model"; import { HttpClient } from "@angular/common/http"; import { TestUtil } from "../../utils/test.uti"; describe('DropDownEditionHistoryItemModel', () => { let i18nService: I18nService; beforeAll(() => { TestBed.configureTestingModule({ declarations: [HttpClient], imports: [HttpClient], providers: [HttpClient] }); i18nService = TestUtil.geti18nService(TestBed.get(HttpClient)); }); it('asdasd', () => { let model: EditionHistoryEventsModel = new EditionHistoryEventsModel(i18nService); expect(true).toBeTruthy(); }); });