I dont seem to find any good article for testing things in app.module.ts I recently using ngx-translate library and I have the code in app.module.ts
I am wondering how to write test against code in app.module.ts The Sonar cloud always complain about test coverage. I don't find a way to test the code in app.module.ts Only way just move all these to share lib
import { Observable, of } from "rxjs";
const enLang = require("../assets/i18n/en-US.json");
const frLang = require("../assets/i18n/fr-FR.json");
const languages = {
"en-US": enLang,
"fr-FR": frLang,
}
class JsonLoader implements TranslateLoader {
getTranslation(lang: string): Observable<any> {
return of(languages[lang]);
}
}
@NgModule({
declarations:
[AppComponent],
imports: [
TranslateModule.forRoot({
loader: { provide: TranslateLoader, useClass: JsonLoader }
}),
],