Я работаю над созданием приложения в бета-версии Angular2, и когда я запускаю свой тестовый пример, я случайно получаю ошибку:
Селектор "#root0" не соответствует ни одной ошибке элементов.
Код теста:
@Component({
template: '',
directives: [GroupBox, GroupBoxHeader]
})
class TestComponent {
}
describe('group-box control', () => {
it('should show the title', injectAsync([TestComponentBuilder], (tcb) => {
return tcb.overrideTemplate(TestComponent, '<group-box><group-box-header>Title Content</group-box-header></group-box>')
.createAsync(TestComponent).then( (fixture) => {
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled).toContainText('Title Content');
});
}));
it('should show the body', injectAsync([TestComponentBuilder], (tcb) => {
return tcb.overrideTemplate(TestComponent, '<group-box><group-box-header>Title Content</group-box-header>Body Content</group-box>')
.createAsync(TestComponent).then( (fixture) => {
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement;
expect(compiled).toContainText('Body Content');
});
}));
});
Я использую Karma с Jasmine, следуя рекомендациям https://github.com/juliemr/ng2-test-seed
Следующий репозиторий воспроизводит ошибку: https://github.com/cangosta/ng2_testing_controls.
Трассировки стека:
Это исправлено в Angular 2.0.0-beta.3.