【问题标题】:angular- ngx-bootstrap throws error when running unit test with karmaangular-ngx-bootstrap 在使用 karma 运行单元测试时抛出错误
【发布时间】:2017-08-28 00:33:22
【问题描述】:

我目前遇到与 Karma 一起运行的 ngx-bootstrap 的问题。 问题是“Chrome 57.0.2987 (Windows 10 0.0.0) 错误 未捕获的类型错误:无法读取未定义的属性“输出” 在 node_modules/ngx-bootstrap/bundles/ngx-bootstrap.umd.js:8087"

我正在使用 Angular 4.0.0 和“ngx-bootstrap”:“^1.6.6”。这是我的配置

1.包.json

"dependencies":
  { 
        "@angular/common": "~4.0.0",
        ........................
        "ngx-bootstrap": "^1.6.6"
  }

2。 Systemjs.config.js

  System.config({
  ......................
    map: {            
        // angular bundles
        ..............................
        'ngx-bootstrap': 'npm:ngx-bootstrap/bundles/ngx-bootstrap.umd.js',                     
    }

});

3. karma.conf.js

module.exports = function (config) {
..................   
config.set({
    basePath: '',
    frameworks: ['jasmine'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'), // click "Debug" in browser to see it
      require('karma-htmlfile-reporter') // crashing w/ strange socket error
    ],   
    files: [          
        ...................
       'node_modules/ngx-bootstrap/bundles/ngx-bootstrap.umd.js',         
    ]     

…………
}) }

请帮助我找出问题所在。 (Web 应用使用 ngx-bootstrap 运行良好)

谢谢!

【问题讨论】:

    标签: angular


    【解决方案1】:

    karma.conf.js 中,替换:

    node_modules/ngx-bootstrap/bundles/ngx-bootstrap.umd.js
    

    与:

    {
      pattern: 'node_modules/ngx-bootstrap/bundles/ngx-bootstrap.umd.js',
      included: false,
      watched: false
    }
    

    然后就可以了。

    【讨论】:

      猜你喜欢
      • 2020-05-26
      • 2019-07-20
      • 2016-06-24
      • 2021-09-06
      • 2019-06-09
      • 1970-01-01
      • 1970-01-01
      • 2020-04-02
      • 1970-01-01
      相关资源
      最近更新 更多