and can translate using this.18n.t("key") properly.
However, in the context of unit-tests, it only returns the passed key and is not translating anything.
I have tested with the following initialization code (with parameters similar to app.module.ts, but adjusted path)
When executing the following line inside my service,
const s = await this.18n.t("exampleKey")
In the context of a unit test, calling it will simply return 'exampleKey.' However, when the application is run, it will work correctly and return the actual string from the JSON file.
The path in my example is correctly resolved; otherwise, an error message would have appeared. In my case, no errors were thrown.
Happening with versions from 9.0.9, 9.0.10 and 10.2.6
I came across that when running unit-tests via jest, the
t
method returns the passed Key and is not doing any translation.I pass the
I18nService
into my service:and can translate using
this.18n.t("key")
properly. However, in the context of unit-tests, it only returns the passed key and is not translating anything.I have tested with the following initialization code (with parameters similar to app.module.ts, but adjusted path)
When executing the following line inside my service,
const s = await this.18n.t("exampleKey")
In the context of a unit test, calling it will simply return 'exampleKey.' However, when the application is run, it will work correctly and return the actual string from the JSON file.
The path in my example is correctly resolved; otherwise, an error message would have appeared. In my case, no errors were thrown.
Happening with versions from 9.0.9, 9.0.10 and 10.2.6