2014-12-29 2 views
1

저는 정말 재스민 jquery를 jasmine과 함께 사용하려고합니다. 그것은 DOM을 산들 바람처럼 조작 할뿐만 아니라 많은 유용한 matchers를 제공 할 것입니다. 이것이 무엇을 의미하는지정의가 정의되지 않았습니다.

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' 
    } 
    */ 
    }); 

내가 한 짓을했는지, per the instructions는 다운로드 JQuery와, 다운로드 자스민 - JQuery와 후와는 카르마의 스펙 파일에이 필요하다 :

files: [ 
     'vendor/assets/bower_components/jquery/src/jquery.js', // added this first 
     'vendor/assets/jasmine-jquery.js',      // and then this... 
     ] 

그러나 JQuery와 나를주는 유지 undefined는 정의되지 않은 오류입니다.

경로가 잘못되었다는 경고가 표시되지 않습니다.

그래서 jasmine-jquery가 어떻게 작동합니까?

필요가있을 수 있습니다 작동하도록하는 것과 관련이 있습니까?

답변

0

the response to this question에서 언급했듯이 npm이 jasmine-query를 다운로드해야합니다. karma.conf.js을 다음과 같이 변경해야합니다.

frameworks: ['jasmine-jquery', 'jasmine'] 
관련 문제