在grunt-contrib-jasmine任务中运行jasmine-jquery时出错

时间:2016-02-18 16:44:36

标签: javascript jquery jasmine-jquery grunt-contrib-jasmine

我试图在我的单元测试中使用jasmine-jquery来测试BackboneJS视图,但是当我尝试运行测试时出现以下错误:

  
    

运行“jasmine:src”(jasmine)任务

         

通过PhantomJS测试茉莉花规格

         

TypeError:'undefined'不是对象(评估'jasmine.spiedEventsKey = function(selector,eventName){         return [$(selector).selector,eventName] .toString()       在

         

测试/供应商/茉莉jquery的主/ LIB /茉莉的jquery.js:40

         

test / vendor / jasmine-jquery-master / lib / jasmine-jquery.js:34

         

test / vendor / jasmine-jquery-master / lib / jasmine-jquery.js:838

  

我正在使用grunt,phantomjs,grunt-contrib-jasmine任务和grunt-template-jasmine-requirejs。

这是我的笨蛋配置

    jasmine : {
        src : 'lib/**/*.js',
        options : {
            vendor: [
                'test/vendor/Sinon/sinon-1.14.1.js',
                'test/vendor/jasmine-jquery-master/vendor/jquery/jquery.js',
                'test/vendor/jasmine-jquery-master/lib/jasmine-jquery.js'
            ],
            specs: 'test/spec/**/*.js',
            helpers: 'test/helpers/**/*.js',
            template: require('grunt-template-jasmine-requirejs'),
            templateOptions: {
                requireConfigFile: 'lib/js/main.js',
                requireConfig: {
                    baseUrl: './lib/js/',
                    paths: {
                        'app': 'app',
                        'router': 'router',
                        'text': './text-master/text',
                    }
                }
            }
        }
    },

我是否错误地设置了这个或者我无法无头地运行jasmine-jquery?

由于

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。通过在我的karma.conf.js文件中以不同的顺序包含框架来修复它。

错误:

frameworks: ['phantomjs-shim', 'jasmine', 'jasmine-jquery']

正确的:

frameworks: ['phantomjs-shim', 'jasmine-jquery', 'jasmine']
相关问题