question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Template parse errors: The pipe "translate" could not be found

See original GitHub issue

Karma 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 this

beforeEach(() => {
    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:closed
  • Created 7 years ago
  • Comments:12

github_iconTop GitHub Comments

20reactions
saiy2kcommented, Aug 29, 2017

@ocombe Can you please tell how to fix this issue Pipe translate could not be found in ngx-translate@7.x?

15reactions
ocombecommented, Jan 3, 2017

Hi, you just need to import the module into your testbed (like you would for any other module, like HttpModule or RouterModule):

beforeEach(() => {
    TestBed.configureTestingModule({
        imports: [TranslateModule.forRoot({
            provide: TranslateLoader,
            useFactory: (http: Http) => new TranslateStaticLoader(http, 'public/assets/i18n', '.json'),
            deps: [Http]
        })],
        declarations: [SidenavComponent] // declare the test component
    });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

The pipe 'translate' could not be found , angular2 ...
I am working on component testing with angular2. in my html template i use the translate pipe. This is the ...
Read more >
NG0302: The pipe 'translate' could not be found! - Ionic Forum
I have a strange issue with translate module. I try to describe the scenario: Main page ClubSettingsMenuComponent (it is a Popover Menu) ...
Read more >
Fix Ngx-translate pipe not found in Angular 11 error [solved]
In this case I use a core module (which acts like a "shared" module). Within the core module is a header component which...
Read more >
Template parse errors: The pipe 'translate' could not be found
Template parse errors : The pipe 'translate' could not be found · 解决办法:把the Translate module 重新导入导出in my app's shared module. · 1、app.
Read more >
NG0302: Pipe not found!
Debugging the errorlink ... Use the pipe name to trace where the pipe is declared and used. To resolve this error, ensure that:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found