【发布时间】:2017-05-23 10:33:35
【问题描述】:
我有一个名为“myPipe”的自定义管道。我得到:
找不到管道“myPipe”错误
在我的单元测试 ts.请建议在我的 .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吗? -
还要检查这个“找不到管道”条目:stackoverflow.com/questions/39007130/…
标签: unit-testing angular