簡體   English   中英

嘗試使用RequireJS進行EmberJS的Karma測試

[英]Trying to get Karma tests up with EmberJS using RequireJS

我正在嘗試使用http://karma-runner.github.io/0.8/plus/RequireJS.html來啟動並運行我的測試。 我的karma.conf.js文件是:

//業力配置//生成於2014年2月12日,星期三13:35:05 GMT-0500(EST)

module.exports = function(config) {
  config.set({
    basePath: 'scripts',
    frameworks: ['qunit', 'requirejs'],
    files: [
      '../tests/test-bootstrap.js',
      {pattern: '../tests/**/*Spec.js', included: false}
    ],
    exclude: [

    ],
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: false,
    browsers: ['PhantomJS'],
    captureTimeout: 60000,
    singleRun: true
  });
};

我的test-bootstrap.js文件是:

tests = [];

for (file in window.__karma__.files) {
  if (window.__karma__.files.hasOwnProperty(file)) {
    if (/Spec\.js$/.test(file)) {
      tests.push(file);
    }
  }
}

console.log(tests);

requirejs.config({
  baseUrl: "scripts",
  paths: {
    jquery: "../lib/jquery",
    underscore: "../lib/underscore"
  },
  shim: {
    underscore: {
      exports: "_"
    }
  },
  deps: tests,
  callback: window.__karma__.start
});

如何獲得允許CoffeeScript文件的文件?

您可能必須預編譯coffeescript文件。 看看https://github.com/karma-runner/karma-coffee-preprocessor

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM