Angular- NGX-Bootstrap使用业力运行单元测试时会引发错误



我当前正在与Karma一起运行NGX-Bootstrap问题。问题是" Chrome 57.0.2987(Windows 10 0.0.0(错误 未定义的typeerror:无法读取未定义在node_modules/ngx-bootstrap/bundles/ngx-bootstrap.umd.js:8087 " ">

我使用的是Angular 4.0.0和" ngx-bootstrap":"^1.6.6"。这是我的配置

1。package.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运行良好(

谢谢!

karma.conf.js中,替换:

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

with:

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

然后起作用。

最新更新