我无法让Karma通过RequireJS加载我的Jasmine规格。我从遵循文档开始,然后使用npm karma init生成karma.conf.js和main-test.js。
问题似乎出在RequireJS加载文件上,路径似乎正确,但是启动Jasmine的require回调从未触发,并且在30秒后,我在控制台中出现超时错误。
我已经尝试了一些方法来缩小范围,但是无论我做什么,RequireJS似乎都没有包含我的foo_spec.js。任何帮助表示赞赏:-)
文件系统
U1
karma.conf.js
U2
test-main.js
karma.conf.js
test-main.ks
/unitTests
foo_spec.js
/myApp
foo.js
foo_spec.js
// Karma configuration
// Generated on Fri Dec 07 2018 11:24:00 GMT-0600 (Central Standard Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'requirejs'],
// list of files / patterns to load in the browser
files: [
'test-main.js',
{ pattern: '/unitTests/foo_spec.js', included: false },
],
// list of files / patterns to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
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: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}