我对茉莉和业力都很陌生,但我有一个使用requirejs和jasmine设置的rails应用程序,我试图让karma运行起来。我运行它,但是当我运行unit.js配置文件时,我收到以下错误。
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 35.0.1916 (Linux)]: Connected on socket PFOOqf9ZbOB_Tv7zhugx with id 60346244
Chrome 35.0.1916 (Linux) ERROR
Uncaught object
at /home/parallels/Code/Test/src/node_modules/requirejs/require.js:141
WARN [web-server]: 404: /people.js
WARN [web-server]: 404: /jquery.js
WARN [web-server]: 404: /page.js
WARN [web-server]: 404: /dropzone.js
require.js中的第141行是
function defaultOnError(err) {
throw err; //<-- this is 141
}
这是我的karma unit.js配置文件。
// Karma configuration
// Generated on Thu Jul 10 2014 08:25:37 GMT-0400 (EDT)
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: [
{ pattern: 'spec/javascripts/extensions/*_spec.js', included: true },
{ pattern: 'spec/javascripts/*_spec.js', included: true }
],
// list of files 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: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
我不确定问题是什么,但根据404消息,我猜测它可能与requirejs无法找到这4个javascript文件有关。如果我手动运行我的茉莉花规格他们都运行正常,所以我不太确定它在哪里/为什么会崩溃。有人有主意吗?感谢。
编辑:
我已根据karma + requireJS文档更新了我的代码。它似乎让我更进一步,但现在我只是得到一个通用错误,没有太多的消息,知道发生了什么。
当我进行业力测试时,我得到了这个....
karma start spec/karma/config/unit.js
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 35.0.1916 (Linux)]: Connected on socket OwrWtfnBJ4zB6DERU0cI with id 70596022
Chrome 35.0.1916 (Linux): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
我的文件夹结构如下
src
--app
----assets
------javascripts
--------application.js, global.js,page.js, routes.js, people.js, etc
--spec
----javascripts
------*_spec.js
----karma
------config
--------unit.js, test-main.js
--vendor
----assets
------javascripts
--------dropzone.js, icheck.js, jquery-ui.js, mustache.js