【问题标题】:How to fix "Can't find variable: jasmine" error when trying to use jasmine-jquery?尝试使用 jasmine-jquery 时如何解决“找不到变量:jasmine”错误?
【发布时间】:2016-06-06 20:03:41
【问题描述】:

我正在尝试设置 jasmine-jquery 以用于 Jasmine 2.4。我的 Gruntfile 配置如下所示:

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-jquery 可能无法与较新版本的 Jasmine 配合使用。想法?

这是错误的截图:

【问题讨论】:

    标签: node.js gruntjs jasmine jasmine-jquery


    【解决方案1】:

    上面的sn-p无效,应该如下

    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
              }
            }
          }
        }
      }
    }
    

    除非茉莉花对象是另一个对象的一部分

    【讨论】:

    • 它是另一个对象的一部分;这不是我认为的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-21
    • 2015-08-16
    • 1970-01-01
    相关资源
    最近更新 更多