无法在我的单元测试中访问CSS属性

时间:2017-09-23 17:25:12

标签: javascript angular unit-testing karma-jasmine

我一直在尝试运行单元测试来检查我的Angular 4+应用程序中的一些CSS属性,但它们的值始终为空。这是我的测试:

it('should have a background a color', () => {
  const toolbar = debug.query(By.css('.toolbar'));
  const toolbarEl = toolbar.nativeElement;
  expect(toolbarEl.style.background).toBeTruthy();
});

失败: Expected '' to be truthy.

console.log:空字符串。

在我的组件的CSS(toolbar.component.scss)中,我有以下类:

.toolbar {
  width: 100%;
  background: blue;
}

我在这里做错了什么想法?

0 个答案:

没有答案