I created an ApiService
class to be able to handle our custom API queries, while using our own serializer + other features.
ApiSer
[JEST and ANGULAR]
Also, the problem may occur when you use an external module and you do not import it but use it on your service.
Ex:
import { TestBed } from '@angular/core/testing';
import from '@ngx-translate/core';
import { SettingsService } from '../../../app/core/services/settings/settings.service';
describe('SettingsService', () => {
let service: SettingsService;
beforeAll(() => {
TestBed.configureTestingModule({
providers: [
SettingsService,
]
});
service = TestBed.inject(SettingsService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
Errors will get you nowhere ... But, if you do that this way:
import { TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { SettingsService } from '../../../app/core/services/settings/settings.service';
describe('SettingsService', () => {
let service: SettingsService;
beforeAll(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()], <---
providers: [
SettingsService
]
});
service = TestBed.inject(SettingsService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
Problem disappears.