2014-03-04 34 views
1

我有一个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'], 

})} 

而这一切工作正常,但是我想“autoWatch”只有符合'static_dev/js/angular/**/test/*.js'的文件,这可能吗?

回答

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 

请注意, watched,includedserved默认值是true

“如果autoWatchtrue已设置watchedtrue所有文件将被观察的变化。”

来源:Karma configuration - Files

2
files : [ 
    ... 
    { 
     pattern: 'static_dev/js/angular/**/test/*.js', 
     watched: true 
    } 
] 

试试这个

+2

'看:TRUE'为默认值,对文件/模式必须设置成'FALSE'对于这些的禁用autowatch。 – glepretre