【问题标题】:How to run karma tests in Angular when stylus stylesheets are used?使用手写笔样式表时如何在 Angular 中运行业力测试?
【发布时间】:2019-02-28 15:50:19
【问题描述】:

我不确定我是否正确构建了问题标题。我想使用 ng test 为我的 Angular 7 应用程序运行测试。在我的一个组件中,我使用了 Stylus 样式表:

@Component({
  selector: 'app-root',
  template: ``,
  encapsulation: ViewEncapsulation.None,
  styleUrls: ['../../../../src/app/globalNg1Styles.styl']
})

当我为应用程序提供服务时它工作正常,但当我尝试运行测试时出现此错误:

ERROR in (...)/src/app/globalNg1Styles.styl
Module build failed (from (...)node_modules/stylus-loader/index.js):
TypeError: Cannot read property 'stylus' of undefined at Object.module.exports ((...)node_modules/stylus-loader/index.js:29:33)
 @ ./src/app/catalog.component.ts 18:21-72
 @ ./src/app/catalog.component.spec.ts
 @ ./src sync \.spec\.ts$
 @ ./src/test.ts

我不明白出了什么问题,我该如何解决问题。

【问题讨论】:

    标签: javascript angular testing karma-runner stylus


    【解决方案1】:

    Stylus-loader 版本 (2.5.0) 有错误。更新到 3.0.2 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2019-12-10
      • 2019-12-10
      • 2019-07-20
      • 1970-01-01
      • 2014-10-01
      • 2017-05-30
      • 2019-04-16
      • 2021-01-28
      • 1970-01-01
      相关资源
      最近更新 更多