2014-09-16 2 views
0

많은 문제가 발생한 후 재스민이 내 Yeoman/Angular 설정 작업을했습니다. 이제 grunt serve을 실행하면 Jasmine wasn't injected in your file이라는 메시지가 나타납니다. 또한 브라우저 콘솔에서 Jasmine이 정의되지 않았 음을 알았습니다. 나는 this 문제와 this 스레드를 확인했다. index.htmlkarma.conf.js에는 수동으로 파일이 포함되었지만 운이 없습니다. 게다가, grunt serve을 실행 한 후, 해당 주소는 내 index.html 파일에서 제거됩니다. 내 박쥐 json 너무 재스민에 대한 항목이 있습니다. 내 경험에쟈스민이 제 파일에 삽입되지 않았습니까?

karma.conf.js:

// Karma configuration 
// http://karma-runner.github.io/0.12/config/configuration-file.html 
// Generated on 2014-09-12 using 
// generator-karma 0.8.3 

module.exports = function(config) { 
'use strict'; 

config.set({ 
    // enable/disable watching file and executing tests whenever any file changes 
    autoWatch: true, 

// base path, that will be used to resolve files and exclude 
basePath: '../', 

// testing framework to use (jasmine/mocha/qunit/...) 
frameworks: ['jasmine-jquery', 'jasmine'], 

// list of files/patterns to load in the browser 
files: [ 
    'bower_components/jasmine-jquery/lib/jasmine-jquery.js', 
    'bower_components/jasmine/lib/jasmine-core.js', 
    'bower_components/angular/angular.js', 
    'bower_components/angular-mocks/angular-mocks.js', 
    'bower_components/angular-animate/angular-animate.js', 
    'bower_components/angular-cookies/angular-cookies.js', 
    'bower_components/angular-resource/angular-resource.js', 
    'bower_components/angular-route/angular-route.js', 
    'bower_components/angular-sanitize/angular-sanitize.js', 
    'bower_components/angular-touch/angular-touch.js', 
    'bower_components/angular-bootstrap/ui-bootstrap.js', 
    'app/scripts/**/*.js', 
    //'test/mock/**/*.js', 
    'test/spec/**/*.js', 
    'app/views/*.html' 
], 

// list of files/patterns to exclude 
exclude: [], 

// web server port 
port: 8080, 

// Start these browsers, currently available: 
// - Chrome 
// - ChromeCanary 
// - Firefox 
// - Opera 
// - Safari (only Mac) 
// - PhantomJS 
// - IE (only Windows) 
browsers: [ 
    'PhantomJS' 
], 

// Which plugins to enable 
plugins: [ 
    'karma-phantomjs-launcher', 
    'karma-jasmine', 
    'karma-jasmine-jquery', 
    'karma-ng-html2js-preprocessor' 
], 

preprocessors: { 
    'app/views/*.html': 'ng-html2js' 
}, 

ngHtml2JsPreprocessor: { 
    stripPrefix: 'app/', 
    moduleName: 'views' 
}, 

// Continuous Integration mode 
// if true, it capture browsers, run tests and exit 
singleRun: false, 

colors: true, 

// level of logging 
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG 
logLevel: config.LOG_INFO, 

// Uncomment the following lines if you are using grunt's server to run the tests 
// proxies: { 
// '/': 'http://localhost:9000/' 
// }, 
// URL root prevent conflicts with the site root 
// urlRoot: '_karma_' 
}); 
}; 

bower.json:

{ 
    "name": "yeosalt", 
    "version": "0.0.0", 
    "dependencies": { 
    "angular": "~1.2.0", 
    "json3": "~3.3.1", 
    "es5-shim": "~3.1.0", 
    "bootstrap-sass-official": "~3.2.0", 
    "angular-resource": "~1.2.0", 
    "angular-cookies": "~1.2.0", 
    "angular-sanitize": "~1.2.0", 
    "angular-animate": "~1.2.0", 
    "angular-touch": "~1.2.0", 
    "angular-route": "~1.2.0", 
    "angular-bootstrap": "~0.11.0", 
    "jasmine-jquery": "~2.0.5", 
    "jasmine": "~2.0.4" 
    }, 
    "devDependencies": { 
    "angular-mocks": "~1.2.0", 
    "angular-scenario": "~1.2.0", 
    "jasmine-jquery": "~2.0.5" 
    }, 
    "appPath": "app" 
} 

답변

1

를, "재스민 파일에 주입되지 않았다"당신의 bower.json 구성에 기인한다 :이 내 파일입니다. 그들은 단지 테스트 목적을 위해 사용되기 때문에

다음 줄

"jasmine-jquery": "~2.0.5", 
"jasmine": "~2.0.4" 

필요 "devDependencies"가 아니라 "의존성"에서 할 수 있습니다.

"dependencies"아래에 정말로 갖고 싶다면, grunt은 당신이 grunt config에 특정 파일을 추가 할 때까지 파일이 삽입되지 않았 음을 경고합니다.

두 번째 문제 ("jasmine is undefined")에 대해서도 한 번이 문제가 발생했습니다. 갈아 타는 재스민 버전 (https://github.com/velesin/jasmine-jquery/issues/168) 사이에 문제가 있었던 것으로 보입니다. 내 bower.json에서 내가 (더 자스민이 필요하지 않습니다)이 : 내 karma.conf.js에서

"devDependencies": { 
    // ... 
    "jasmine-jquery": "~1.3.1" 
}, 

을, 나는 파일 설정의 상단에 있습니다

files: [ 
    'bower_components/jquery/dist/jquery.min.js', 
    'bower_components/jasmine-jquery/lib/jasmine-jquery.js', 
    // ... 
] 

을 그리고 내가 할 수 있었다 재스민 변수를 사용합니다.

희망은 도움이 될 것입니다.

관련 문제