1
我想知道是否可以配置Karma(0.10.9)在其requirejs框架之前加載某些JavaScript文件?我要問的原因是Knockout註冊爲RequireJS模塊,如果後者已經包含在Knockout之前,並且這打破了另一個模塊(它不支持RequireJS)。Karma:是否可以在requirejs框架之前靜態加載JavaScript文件?
基本上,我們karma.conf.js看起來如下:
module.exports = function (config) {
config.set({
basePath: "Scripts",
frameworks: ['mocha', 'requirejs'],
files: [
"knockout-2.2.1.debug.js",
"knockout.viewmodel.2.0.3.js",
{pattern: "test/**/*.js", included: false},
{pattern: "shared/**/*.js", included: false},
{pattern: "app/**/*.js", included: false},
],
reporters: ['progress', 'growl'],
// web server port
// CLI --port 9876
port: 9876,
// cli runner port
// CLI --runner-port 9100
runnerPort: 9100,
autoWatch: true,
browsers: ["PhantomJS"],
// If browser does not capture in given timeout [ms], kill it
// CLI --capture-timeout 5000
captureTimeout: 5000,
// Auto run tests on start (when browsers are captured) and exit
// CLI --single-run --no-single-run
singleRun: false,
// report which specs are slower than 500ms
// CLI --report-slower-than 500
reportSlowerThan: 500,
plugins: [
'karma-mocha',
'karma-phantomjs-launcher',
'karma-growl-reporter',
'karma-requirejs'
]
});
}
查看https://github.com/karma-runner/karma/issues/699 – Vojta
@Vojta謝謝! – aknuds1
本演示文稿將簡要介紹如何完成此項工作:http://believeblog.azurewebsites.net/post/learn-knockoutjs-with-its-father – Believe2014