xio*_*tee 6 unit-testing karma-jasmine angular-cli angular
我在 Angular 2 中进行测试时遇到问题。
describe('Spinner Component', () => {
beforeEach(() => TestBed.configureTestingModule({
declarations: [SpinnerComponent]
}).compileComponents());
beforeEach(() => {
fixture = TestBed.createComponent(SpinnerComponent);
comp = fixture.componentInstance;
fixture.detectChanges();
});
it('Should Create a Spinner Component', () => {
fixture.detectChanges();
var compiled = fixture.debugElement.nativeElement;
expect(compiled).toBeTruthy();
});
it('Should not be running', () => {
fixture.detectChanges();
expect(comp.isRunning).toBe(false);
});
});
Run Code Online (Sandbox Code Playgroud)
上面的代码显示测试中的 Spinner 组件“不应该运行”。我不知道是什么原因造成的。我在控制台中收到错误消息(请参见下文)。如代码中所示,我已经在每个之前的第二个实例上创建了组件实例,但它指出在第二个测试用例上运行时它是未定义的。我需要帮助。我真的很感激。提前致谢。
| 归档时间: |
|
| 查看次数: |
4606 次 |
| 最近记录: |