jjzjj

DebugElement

全部标签

javascript - 按类不返回元素的 Angular Fixture DebugElement 查询

正如Angular.io框架测试文档所建议的,我一直在尝试使用AngularTestbed+Karma测试运行器来使用DebugElement查询。我创建了一个jqwidgetsTree组件,它生成类'.jqx-tree-item-li'的li元素。以下在DOM测试中直接使用javascript的测试通过了GREEN:it('Elementsofclassjqx-tree-item-lifoundusinggetElementsByClassName',(done)=>{this.fixture.whenStable().then(()=>{varelementArray=docume

javascript - Angular2 测试 : What's the difference between a DebugElement and a NativeElement object in a ComponentFixture?

我目前正在汇总一些在组件级别测试Angular2应用程序的最佳实践。我看过一些教程查询夹具的NativeElement对象以获取选择器等,例如it('shouldrender"HelloWorld!"afterclick',async(()=>{builder.createAsync(HelloWorld).then((fixture:ComponentFixture)=>{fixture.detectChanges();letel=fixture.nativeElement;el.querySelector('h1').click();fixture.detectChanges();