我想知道是否可以配置Karma(0.10.9)在其requirejs框架之前加载某些JavaScript文件?我要问的原因是,如果Knockout在RequireJS之前已包含在RequireJS中,则将其注册为模块,这会破坏另一个模块(不支持RequireJS)。
基本上,我们的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'
]
});
}
最佳答案
显然,可以通过手动包括karma-requirejs文件而不在框架之间包括它来完成:
frameworks: ['mocha'],
files: [
"knockout-2.2.1.debug.js",
"knockout.viewmodel.2.0.3.js",
'node_modules/requirejs/require.js',
'node_modules/karma-requirejs/lib/adapter.js',
{pattern: "test/**/*.js", included: false},
{pattern: "shared/**/*.js", included: false},
{pattern: "app/**/*.js", included: false}
]
请参阅此业力issue以供参考。
关于javascript - karma :是否可以在requirejs框架之前静态加载JavaScript文件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22228399/