Jasmine 定义未定义
我真的很想让jasmine jquery与jasmine一起工作。它不仅可以轻松地操作DOM,还可以为我提供大量有用的匹配工具 但是,当我尝试启动spec runner时,会出现以下错误:Jasmine 定义未定义,jasmine,karma-runner,jasmine-jquery,Jasmine,Karma Runner,Jasmine Jquery,我真的很想让jasmine jquery与jasmine一起工作。它不仅可以轻松地操作DOM,还可以为我提供大量有用的匹配工具 但是,当我尝试启动spec runner时,会出现以下错误: ReferenceError: Can't find variable: define at /.../app/vendor/assets/bower_components/jquery/src/jquery.js:37 你知道这是什么意思吗?我正在使用业力来运行我的规格。这是我的unit.js配置:
ReferenceError: Can't find variable: define
at /.../app/vendor/assets/bower_components/jquery/src/jquery.js:37
你知道这是什么意思吗?我正在使用业力来运行我的规格。这是我的unit.js配置:
module.exports = function(config) {
config.set({
basePath: '..',
// frameworks to use
frameworks: ['jasmine'],
urlRoot: '/_karma_/',
// list of files / patterns to load in the browser
files: [
'vendor/assets/bower_components/angular/angular.js',
'vendor/assets/bower_components/angular-mocks/angular-mocks.js',
'vendor/assets/bower_components/angular-resource/angular-resource.js',
'vendor/assets/bower_components/angular-cookies/angular-cookies.js',
'vendor/assets/bower_components/angular-sanitize/angular-sanitize.js',
'vendor/assets/bower_components/angular-route/angular-route.js',
'vendor/assets/bower_components/jquery/src/jquery.js', // added this first
'vendor/assets/jasmine-jquery.js', // and then this...
'vendor/assets/bower_components/jasmine-jquery/lib/jasmine-jquery.js',
'app/assets/javascripts/application.js.coffee',
'app/assets/javascripts/**/**',
'spec/javascripts/**/*'
],
// list of files to exclude
exclude: [
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['dots'],
// 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,
autoWatch: true,
plugins : [
'jasmine-given',
'requirejs',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-opera-launcher',
'karma-jasmine',
'karma-ng-scenario',
'karma-phantomjs-launcher',
'karma-coffee-preprocessor'
],
browsers: ['PhantomJS','Chrome','Firefox','Opera'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,
// Preprocessors
preprocessors: {
'/**/*.coffee':'coffee',
'**/*.slim': ['slim', 'ng-html2js']
}
/*
ngHtml2JsPreprocessor: {
stripPrefix: 'app/assets/templates/',
stripSufix: '.slim'
}
*/
});
我所做的就是下载jquery,下载jasmine jquery,然后在Karma的规范文件中要求它们:
files: [
'vendor/assets/bower_components/jquery/src/jquery.js', // added this first
'vendor/assets/jasmine-jquery.js', // and then this...
]
但jquery一直告诉我未定义的错误不是已定义的错误
我没有收到因果报应关于道路错误的警告
那么如何让jasmine jquery工作呢
requirejs是否与使其工作有关?如中所述,您需要确保npm下载jasmine query。
您需要在karma.conf.js中更改以下内容:
frameworks: ['jasmine-jquery', 'jasmine']