-
🙏🏻 First of all I am sorry for using the bug template if it is not the appropriate one for my situation. I have a component core.module.ts
fr.json
navbar.component.html
📖 I am introducing ngneat/transloco to my project. I tried following the library's documentation on Unit Testing and it all works well when written as below ⬇️ ✅ navbar.component.spec.ts
😢 But when I try using transloco-testing.module.ts
❌ navbar.component.spec.ts
The error comes from the
Could you please give me a hint of what I am doing wrong ? Thank you ! 🙏🏻 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @mlz11, you can write a test like that: describe('ng-mocks', () => {
beforeEach(() => MockBuilder([
NavbarComponent,
TranslocoModule,
], CoreModule)
.provide(getTranslocoModule().providers ?? [])
);
it('tests translation', () => {
const fixture = TestBed.createComponent(NavbarComponent);
fixture.detectChanges();
expect(fixture.nativeElement.innerHTML).toContain('<span>Hello</span>');
});
});
|
Beta Was this translation helpful? Give feedback.
-
How would it look like according to the new way (providers instead modules)? Transloco is now provided using
It might very well be the problem with transloco itself - not providing 'provider' for tests. |
Beta Was this translation helpful? Give feedback.
Hi @mlz11,
you can write a test like that:
TranslocoTestingModule
usesTranslocoModule
with special providers.So to keep
TranslocoModule
in the test,we just need to keep
TranslocoModule
and to add providers fromTranslocoTestingModule
.