I'm just getting started writting unit tests for angular. As I am using ngx-translate in literally every component (and some services) I wanted to ask if there was a way to import and provide it on a global testing level.
So far I have provided and imported the ngx-translate module and http-loader in each .spec file like this
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
}
}),
],
declarations: [
AppComponent
]
}).compileComponents();
}));
}