Template parse errors: The pipe "translate" could not be found
See original GitHub issueKarma Jasmine unit testing causing Template parse errors: The pipe “translate” could not be found
Current behavior I’m trying to unit test the simple ng2-translation application. Karma Jasmine unit test spec is not recognizing HTML tags, for example
{{‘PAGE.HELLO’ | translate}}
I have written my piece of spec like thisbeforeEach(() => {
TestBed.configureTestingModule({
declarations: [ SidenavComponent ], // declare the test component
providers: [
TranslateService,
{ provide: TranslateLoader, useFactory: (http: Http) => new TranslateStaticLoader(http, 'public/assets/i18n', '.json'), deps:[Http]},
]
});
});
I’m not sure that I’m providing the JSON files in proper format like above. How to resolve this pipe error? Ocombe- Please provide sample unit tests for the examples you have provided in the git
Expected/desired behavior
Reproduction of the problem If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:btpW3l0jr5beJVjohy1Q).
What is the expected behavior?
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
-
ng2-translate version: x.x.x
-
Angular version: 2.1.0-rc.X
-
Browser: [IE 11 ]
-
Language: [all | TypeScript X.X | ES6/7 | ES5]
Issue Analytics
- State:
- Created 7 years ago
- Comments:12
Top GitHub Comments
@ocombe Can you please tell how to fix this issue
Pipe translate could not be found
in ngx-translate@7.x?Hi, you just need to import the module into your testbed (like you would for any other module, like HttpModule or RouterModule):