2014-10-16 25 views
8

Tôi có một vấn đề thực hiện nghiệp grunt: đơn vị, nhiệm vụ đã hoàn thành nhưng ném này:Grunt Karma đơn vị nhiệm vụ thất bại với dự án AngularJS

....... 
DEBUG [web-server]: serving (cached): C:/project/yo 
/test/spec/services/lists.js 
Firefox 32.0.0 (Windows 7): Executed 0 of 0 ERROR (0.027 secs/0 secs) 
DEBUG [karma]: Run complete, exiting. 
DEBUG [launcher]: Disconnecting all browsers 
DEBUG [launcher]: Process Firefox exited with code 0 
DEBUG [temp-dir]: Cleaning temp dir C:\Users\developer\AppData\Local\Temp\karma-14 
854612 
Warning: Task "karma:unit" failed. Use --force to continue. 

Aborted due to warnings. 


Execution Time (2014-10-16 21:25:51 UTC) 
karma:unit 4.1s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100% 
Total 4.1s 

Thư mục kiểm tra bao gồm các bài kiểm tra sản phẩm nào, ví dụ:

'use strict'; 

describe('Service: lists', function() { 

}); 

Tôi không hiểu tại sao kết quả là: Cảnh báo: Tác vụ "nghiệp: đơn vị" không thành công. Sử dụng --force để tiếp tục..

tập tin karma.conf.js My chứa:

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

    config.set({ 
    autoWatch: true, 

    basePath: '../', 

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

    // list of files/patterns to load in the browser 
    files: [ 
     'app/bower_components/jquery/dist/jquery.js', 
     'app/bower_components/angular/angular.js', 
     'app/bower_components/json3/lib/json3.js', 
     'app/bower_components/bootstrap/dist/js/bootstrap.js', 
     'app/bower_components/jquery-ui/jquery-ui.js',  
     'app/bower_components/angular-animate/angular-animate.js', 
     'app/bower_components/angular-route/angular-route.js', 
     'app/bower_components/angular-sanitize/angular-sanitize.js', 
     'app/bower_components/angular-touch/angular-touch.js',  
     'app/bower_components/lodash/dist/lodash.compat.js',  
     'app/bower_components/restangular/dist/restangular.js', 
     'app/bower_components/angular-ui-router/release/angular-ui-router.js', 
     'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.js', 
     'app/bower_components/angular-translate/angular-translate.js', 
     'app/bower_components/angular-moment/angular-moment.js', 
     'app/bower_components/angular-ui-router/release/angular-ui-router.js', 
     'app/bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',  
     'app/scripts/**/*.js', 
     'test/spec/**/*.js' 
    ], 

    exclude: [], 

    port: 8080, 

    browsers: [ 
     'Firefox' 
    ], 

    plugins: [ 
     'karma-firefox-launcher', 
     'karma-jasmine' 
    ], 

    singleRun: false, 

    colors: true, 

    logLevel: config.LOG_DEBUG, 
    }); 
}; 

Trả lời

9

Karma cần ít nhất 1 bài kiểm tra để làm cho nó làm việc/thành công. Hãy xem trong kết xuất debug của bạn:

Firefox 32.0.0 (Windows 7): Executed 0 of 0 ERROR (0.027 secs/0 secs) 

Khi bạn thêm chỉ là một thử nghiệm, nó sẽ làm việc:

Firefox 32.0.0 (Windows 7): Executed 1 of 1 SUCCESS (0.031 secs/0 secs) 

Làm thế nào để làm cho giao diện điều khiển đăng nhập và lỗi của hiển thị trong giao diện điều khiển đầu ra trong khi chạy thử nghiệm?

Hãy thêm progress vào tệp cấu hình nghiệp của bạn.

Bạn có thể đọc về điều này trong tài liệu hướng dẫn ở đây: http://karma-runner.github.io/0.8/config/configuration-file.html

reporters: ['progress'], 
+1

trình báo cáo 'tiến trình' bị thiếu trong cấu hình của tôi (ban đầu được tạo bởi yeoman từ lâu). vì vậy cảm ơn cho gợi ý. – smoebody

+1

Vâng, thử nghiệm của tôi là có. Nhưng tôi vẫn nhận được tin nhắn. PhantomJS 1.9.8 (Linux): Đã thực thi 1 trong số 1 (1 FAILED) L ERI (0.051 giây/0.015 giây) Cảnh báo: Tác vụ "nghiệp: đơn vị" không thành công. Sử dụng --force để tiếp tục. – Stephane

+1

Tôi có một trường hợp thử nghiệm thành công. nó vẫn hiển thị cùng một thông báo cảnh báo. –

3

Bạn có thể thử để loại bỏ: /workspace/node_modules/.karma.DELETE/ hoặc/workspace/node_modules/nghiệp

Sau đó, sudo npm install karma

+1

Chào mừng bạn đến với SO. Chỉ vì tò mò, tại sao bạn cảm thấy cần phải trả lời câu hỏi hơn 2 tuổi? – LotPings

+3

Bởi vì tôi đã có cùng một vấn đề ngày hôm qua, vì vậy nó có thể hữu ích cho người khác –

+1

@LotPings bạn vừa mô tả có lẽ là 30% nội dung trên cộng đồng này. Không có khoảng thời gian hết hạn về thông tin hữu ích – Kristian

Các vấn đề liên quan