Romanchuk / angular-i18next

angular v10+ integration with i18next v19.4+
MIT License
131 stars 33 forks source link

Mock angular-i18next in Jest #115

Closed AlbaSS18 closed 9 months ago

AlbaSS18 commented 9 months ago

Hello,

I am working in an Angular Project. I am doing the test with Jest Library and I need mocking i18next. I don't find it any example on Internet, only for React. For this reason, can someone help me or give me some example?

luca-peruzzo commented 9 months ago

@AlbaSS18 maybe this could be useful: https://github.com/Romanchuk/angular-i18next/blob/master/libs/angular-i18next/src/tests/mocks/MockTranslationService.ts

Romanchuk commented 9 months ago

@luca-peruzzo Thank you! @AlbaSS18 You can implement ITransationService as you want. But do it only if simple options i'll write below doesn't fit for you.

@AlbaSS18 i18next has 'cimode' value for language if you doesn't need to load resources for tests. So you will get expeted values - translation result will be equal to passed keys. That thing made to isolate tests from translations.

@AlbaSS18 Also take a look https://github.com/Romanchuk/angular-i18next#in-project-testing