Karma观看特定文件

Jon*_*now 1 javascript jasmine angularjs karma-runner

karma.conf.js喜欢这样的:

module.exports = function(config){
    config.set({

    files : [
        'static_dev/js/lib/underscore-min.js',
        'static_dev/js/lib/angular.1.2.9.min.js',
        'static_dev/js/lib/angular-cookies.1.1.5.min.js',
        'static_dev/js/lib/ui-bootstrap-custom-tpls-0.10.0.js',
        'static_dev/js/lib/angular-tags-0.2.10-tpls.min.js',
        'static_dev/js/lib/angular-mocks.js',

        'static_dev/js/angular/modules/*.js',
        'static_dev/js/angular/controllers/**/*.js',
        'static_dev/js/angular/directives/**/*.js',
        'static_dev/js/angular/services/**/*.js',

        'static_dev/js/angular/**/test/*.js'
    ],

    reporters: ['progress', 'coverage'],

    autoWatch: true,

    colors: true,

    frameworks: ['jasmine'],

    browsers : ['PhantomJS'],

})}
Run Code Online (Sandbox Code Playgroud)

这一切都很好,但我想"自动观察"只匹配的文件,'static_dev/js/angular/**/test/*.js'这可能吗?

gle*_*tre 5

您应该为文件使用完整的模式语法,这样您就可以禁用对不想要的文件的监视:

files : [
  //this pattern will NOT be watched
  {pattern: 'path/to/**/*.js', watched: false, included: true, served: true},

  //this one will be watched
  {pattern: 'path/to/other/**/*.js', watched: true, included: true, served: true}
],

 autowatch: true
Run Code Online (Sandbox Code Playgroud)

请注意watched,includedserved默认值true.

"如果autoWatchtrue已设置的所有文件watchedtrue会观看了变化."

来自:业力配置 - 文件