1

我正在尝试使用 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

4

0 回答 0