I have a custom pipe called 'myPipe'. I am getting:
The pipe 'myPipe' could not be found error
in my unit test ts. Pleas advice what to import and declare in my .spec.ts
Here is my .spec.ts
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; import { MyComponent } from './main-page-carousel.component'; describe('CarouselComponent', () => { let component: MyComponent ; let fixture: ComponentFixture<MyComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ MyComponent ], }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(MyComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); });
Thanks!
Answer: B) DataPipe Is not built-in a pipe in angular.
Pipes were earlier called filters in Angular1 and called pipes in Angular 2 and 4. It takes integers, strings, arrays, and date as input separated with | to be converted in the format as required and display the same in the browser.
You should be able to do this:
import { MyPipe } from 'here put your custom pipe path'; TestBed.configureTestingModule({ declarations: [ MyComponentUnderTesting, MyPipe ] })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With