首页 > 解决方案 > 无法为子组件单元测试加载父 SCSS 文件

问题描述

单元测试特定子组件不加载父 scss 文件,仅加载全局和自身 scss 文件

有两个组件

  1. A-父组件
  2. B-子组件

A.component.html

<header>
</header>
<router-outlet></router-outlet>

A.component.scss

:host ::ng-deep .inpGroup {
  display: block;
  width: 100%;
  height: 50px;
}

B.component.html

<div class="inpGroup">

</div>

在对 b.component.spec.ts 应用角度单元测试后,如何加载在 B 组件中使用的 A.component.scss。我试过,在子组件规范中加载父组件。

标签: angularkarma-jasmine

解决方案


推荐阅读