Unit Testing
When running specs, we want to have the languages available immediately, in a synchronous fashion. Transloco provides you with a TranslocoTestingModule
, where you can pass the languages you need in your specs, and the config.
We recommend to be DRY and create a module factory function that we can use in each spec, For example:
transloco-module.spec.ts
Now we can use it in each spec
file:
app.component.spec.ts
You can find an example here.
If you need to test scopes
, you should add them as languages
, for example:
transloco-module.spec.ts
You can find an example here.
Note that in order to import JSON files, you need to configure the TypeScript compiler by adding the following properties in tsconfig.json
: