Core: The pipe 'translate' could not be found

Created on 15 Aug 2017  路  3Comments  路  Source: ngx-translate/core

I'm submitting a ... (check one with "x")

[ x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior
ngx-translate is impossible to test.

    beforeEach(() => {
        TestBed.configureTestingModule({
            declarations: [TileComponent],
            providers: [TranslatePipe]
        });
        fixture = TestBed.createComponent(TileComponent);

Expected/desired behavior

Spend more time on SEO instead of github issue templates:
http://lmgtfy.com/?q=The+pipe+%27translate%27+could+not+be+found

Most helpful comment

Do you want to test your TileComponent or do you want to test the pipe?

In our project we go the way to mock the translatepipe:

@Pipe({
    name: "translate"
})
export class TranslatePipeMock implements PipeTransform {
    public name: string = "translate";

    public transform(query: string, ...args: any[]): any {
        return query;
    }
}

and then use that mock in the testbed:
declarations: [TranslatePipeMock]

All 3 comments

Do you want to test your TileComponent or do you want to test the pipe?

In our project we go the way to mock the translatepipe:

@Pipe({
    name: "translate"
})
export class TranslatePipeMock implements PipeTransform {
    public name: string = "translate";

    public transform(query: string, ...args: any[]): any {
        return query;
    }
}

and then use that mock in the testbed:
declarations: [TranslatePipeMock]

Any suggestions in my issue #627??

For problemns with Jasmine test.

Its works for me guys 馃槈

Add this on MyComponent..component.spec.ts
import { TranslateModule } from "@ngx-translate/core";

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EmailMessageComponent ],
imports: [
TranslateModule.forRoot(),
]
})
.compileComponents();
}));

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pndewit picture pndewit  路  3Comments

louisdoe picture louisdoe  路  3Comments

egornoveo picture egornoveo  路  4Comments

gmquiroga picture gmquiroga  路  3Comments

jstoup111 picture jstoup111  路  4Comments