我有一個名爲'myPipe'的自定義管道。我得到我的單元測試ts中找不到'myPipe'管道錯誤。這裏Angular 2單元測試:自定義管道錯誤找不到管道
普萊斯建議如何導入並宣佈在我.spec.ts
是我.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();
});
});
謝謝!
你說的是'myPipe',但是你的測試和'CarouselComponent'有關?你不應該導入'myPipe'? –
檢查此「管道未找到」條目:http://stackoverflow.com/questions/39007130/the-pipe-could-not-be-found-angular2-custom-pipe/40770507#40770507 – Karl