angulartypescriptlocalizationjasmineangular-localize

Angular localize in jasmine unit test


I am trying to test translation in angular with jasmine. I am using angular localize but I do not know how to use it inside jasmine/karma unit tests. I trigger language change via URL parameter which is suitable for e2e tests where it works fine. Thanks for any suggestions on how to change language in jasmine.


Solution

  • solved.

    tsconfig

    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    

    spec file

    import { loadTranslations } from '@angular/localize';
    import de from '../assets/de.json';
    loadTranslations(de);