我正在尝试使用Karma,Jasmine和Phantomjs建立一个角度测试环境。这是一个使用hamlcoffee作为模板语言的rails应用程序。
我的问题是,当我尝试运行测试时,我收到以下错误:
PhantomJS 1.9.7 (Linux) ERROR
SyntaxError: Parse error at /home/me/.rvm/gems/ruby-2.1.2/bundler/gems/haml_coffee_assets-a3c2951eca00/vendor/assets/javascripts/hamlcoffee.js.coffee.erb:1
文件hamlcoffee.js.coffee.erb
看起来像是问题所在,所以我尝试将以.erb
结尾的所有内容添加到karma配置文件中的排除列表中,但遗憾的是没有运气。
这是我的Karma配置文件:
// Karma configuration
module.exports = function(config) {
config.set({
// base path, based on tmp/ folder
basePath: '..',
// frameworks to use
frameworks: ['jasmine', 'ng-scenario'],
// list of files / patterns to load in the browser
files: [
APPLICATION_SPEC,
'app/assets/javascripts/*/*.{coffee,js}',
'spec/javascripts/**/*_spec.{coffee,js}',
'app/assets/*.haml'
],
// list of files to exclude
exclude: [
'**/*.erb'
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['PhantomJS'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,
// Preprocessors
preprocessors: {
'**/*.coffee' : 'coffee',
'app/assets/javascripts/**/*.hamlc' : 'haml'
},
hamlPreprocessor: {
options: {
language: 'coffee'
}
}
});
};
我正在使用karma-haml-preprocessor作为我的.hamlc
模板。