Unit Testing
When running tests, it's important to have the languages available immediately and synchronously. Transloco provides the TranslocoTestingModule
, which allows you to specify the languages and configuration needed for your specs.
To follow the DRY (Don't Repeat Yourself) principle, it's a good idea to create a module factory function that can be reused in each spec. Here's an example:
transloco-testing.module.ts
Using the module in your spec files
app.component.spec.ts
Testing scopes
If you need to test scopes, you should add them as languages. For example:
transloco-testing.module.ts
TypeScript Configuration
To import JSON files in your TypeScript project, you need to update your tsconfig.json
with the following properties:
Last updated
Was this helpful?