Javascript 如何使用jasmin和karma测试外部css属性
如何使用jasmine karma测试外部css属性Javascript 如何使用jasmin和karma测试外部css属性,javascript,css,angular,unit-testing,karma-jasmine,Javascript,Css,Angular,Unit Testing,Karma Jasmine,如何使用jasmine karma测试外部css属性 。购买{ 宽度:50%; } 您好,我想检查宽度属性 您不能将50作为一个值进行检查,但可以使用以下方法获得计算的宽度值: it('should create', () => { expect(component).toBeTruthy(); const e = fixture.debugElement.query(By.css(".test")).nativeElement; console.log(g
。购买{
宽度:50%;
}
您好,我想检查宽度属性
您不能将50
作为一个值进行检查,但可以使用以下方法获得计算的宽度
值:
it('should create', () => {
expect(component).toBeTruthy();
const e = fixture.debugElement.query(By.css(".test")).nativeElement;
console.log(getComputedStyle(e).width)
// you can get value as '442.5px' or something
});
不建议检查此类琐碎属性,除非必须检查您不能将
50
作为值进行检查,但您可以使用以下方法获得计算的宽度
值:
it('should create', () => {
expect(component).toBeTruthy();
const e = fixture.debugElement.query(By.css(".test")).nativeElement;
console.log(getComputedStyle(e).width)
// you can get value as '442.5px' or something
});
除非必须检查,否则不建议检查这些琐碎的属性我的回答对您有帮助吗?请把它标记为一个答案,这样它可以帮助其他寻找类似问题的人。我的答案对你有帮助吗?请将其标记为答案,以便帮助其他人寻找类似问题