I'm trying to test a service with jasmine but i have this error:
Error: Unexpected value 'CookieService' imported by the module 'DynamicTestModule'. Please add an @NgModule annotation.
and
Error: Expected undefined to be truthy.
My spec file:
import { RouterTestingModule } from '@angular/router/testing';
import { TestBed } from '@angular/core/testing';
import { Api } from './api.service';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, Inject, Injectable } from '@angular/core';
import { CookieService } from 'ngx-cookie';
fdescribe('ApiService', () => {
let service: Api;
let httpMock: HttpTestingController;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
Api,
],
imports: [
HttpClientTestingModule,
RouterTestingModule,
CookieService
],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
});
});
beforeEach(() => {
service = TestBed.inject(Api);
httpMock = TestBed.inject(HttpTestingController);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});