我已經爲基於angular-cli的項目創建了一個非常簡單的示例測試。從標題中可以看出,問題在於TestComponentBuilder.createAsync()沒有解決它的承諾。這是我的代碼。我懷疑問題出在karma-test-shim.js配置文件中,但我不確定這一點。儘管我已經爲我的測試設置了「expect(true).toEqual(false)」,但測試的結果總是成功。我與角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 {
}