나는 angular-cli를 기반으로하는 프로젝트에 대해 매우 간단한 샘플 테스트를 만들었습니다. 제목에서 알 수 있듯이 TestComponentBuilder.createAsync()가 약속을 해결하지 못하는 이유가 문제입니다. 여기 내 코드가있다. 나는이 문제가 karma-test-shim.js 설정 파일에 있다고 의심하지만 이것에 대해서는 잘 모르겠습니다. 테스트 결과는 필자가 테스트를 위해 "expect (true) .toEqual (false)"로 설정했지만 항상 성공합니다. 난 당신이 async
으로 inject
기능 비동기 테스트를 포장 할 필요가 각 2 RC4에서 각도 2 RC4Angular-CLI TestComponentBuilder.createAsync()가 약속을 해결하지 못함
import {
beforeEach,
beforeEachProviders,
describe,
expect,
it,
inject
} from '@angular/core/testing';
import { ComponentFixture, TestComponentBuilder } from '@angular/core/testing';
import { Component } from '@angular/core';
import { By } from '@angular/platform-browser';
describe('Component: CollectionCounterWidgetComponent',() => {
let builder: TestComponentBuilder;
beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
builder = tcb;
}));
it('should create the CollectionCounterWidgetComponent component', inject([],() => {
return builder.createAsync(ComponentTestController)
.then((fixture: ComponentFixture<any>) => {
fixture.detectChanges();
expect(true).toEqual(false);
});
}));
});
@Component({
selector: 'test',
template: `
<h1>why?</h1>
`
})
class ComponentTestController {
}