首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复尝试使用jasmine-jquery时出现的"Can't find variable: jasmine“错误?

如何修复尝试使用jasmine-jquery时出现的"Can't find variable: jasmine“错误?
EN

Stack Overflow用户
提问于 2016-02-24 21:36:31
回答 1查看 504关注 0票数 0

我正在尝试设置jasmine-jquery以便与Jasmine 2.4一起使用。我的Gruntfile配置如下所示:

代码语言:javascript
复制
jasmine : {
  main: {
    // src: 'htdocs/test/newjs/**/*.js',
    options: {
      specs: 'htdocs/test/newjs/*.js',
      vendor: 'htdocs/jslib/jasmine-jquery-1.5.0/jasmine-jquery.js',
      template: require('grunt-template-jasmine-requirejs'),
      templateOptions: {
        requireConfigFile: 'htdocs/js/config.js',
        requireConfig: {
          baseUrl: './htdocs/js/',
          callback: function($) {
            // Extra initialization here
          },
          paths: {
            jquery:   '../jslib/jquery-1.9.1/jquery.min',
            facebook: '../jslib/connect.facebook.net-test/en_US/all',
            'jquery.mobile':   '../jslib/jquery.mobile.touchonly-1.3.2/'+
                'jquery.mobile.custom.min',
             templates:  '../templates',
             config: 'empty' // Override config require since this plugin
                              // already pulls it into the test runner
          }
        }
      }
    }
  }
},

然而,我一直收到“无法找到变量: jasmine”的错误信息。有没有人有处理这个错误的经验?我听说jasmine-jquery在新版本的Jasmine上可能不能很好地发挥作用。有什么想法?

以下是错误的屏幕截图:

EN

回答 1

Stack Overflow用户

发布于 2016-02-25 10:54:24

上述代码段无效,应如下所示

代码语言:javascript
复制
var jasmine = {
  main: {
    // src: 'htdocs/test/newjs/**/*.js',
    options: {
      specs: 'htdocs/test/newjs/*.js',
      vendor: 'htdocs/jslib/jasmine-jquery-1.5.0/jasmine-jquery.js',
      template: require('grunt-template-jasmine-requirejs'),
      templateOptions: {
        requireConfigFile: 'htdocs/js/config.js',
        requireConfig: {
          baseUrl: './htdocs/js/',
          callback: function($) {
            // Extra initialization here
          },
          paths: {
            jquery:   '../jslib/jquery-1.9.1/jquery.min',
            facebook: '../jslib/connect.facebook.net-test/en_US/all',
            'jquery.mobile':   '../jslib/jquery.mobile.touchonly-1.3.2/'+
                'jquery.mobile.custom.min',
             templates:  '../templates',
             config: 'empty' // Override config require since this plugin
                              // already pulls it into the test runner
          }
        }
      }
    }
  }
}

除非jasmine对象是另一个对象的一部分

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35603728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档