我已经为基于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 {
}