Когда я забегаю grunt jasmine
, все мои спецификации проходят, но когда я бегу grunt karma
Карма в основном бесшумно терпит неудачу, так как «Предупреждение: задача« карма: единица »не удалась. Использовать -force для продолжения. Прерывание из-за предупреждений». почти ничего не говорит. Если я удалю все мои $ httpBackend чеки, то grunt karma
снова пройдет. Похоже, что это происходит, когда я добавляю метод flush()
.
Угловые и угловые-Mocks находятся на 1.2.26.
Кто-нибудь знает, почему мои юнит-тесты терпят неудачу в Карме, а не в Жасмине?
'use strict';
describe('DashboardCtrl spec', function() {
var $scope,
$route,
$controller,
$httpBackend;
// Load the services's module
beforeEach(module('LocalStorageModule'));
beforeEach(module('myApp'));
beforeEach(inject(function(_$controller_, $rootScope, _$route_, _$httpBackend_) {
$scope = $rootScope.$new();
$route = _$route_;
$httpBackend = _$httpBackend_;
$controller = _$controller_;
$httpBackend.expectGET('//localhost:8081/api1/api/things1/').respond({});
$httpBackend.expectGET('//localhost:8081/api1/api/things2/').respond({
'next': 'somepage.html'
});
$httpBackend.expectGET('views/dashboard.html').respond('<p></p>');
$controller('DashboardCtrl', {$scope: $scope, $route: { current: { params: ''}}});
$httpBackend.flush();
$scope.$digest();
}));
describe('$scope.init()', function() {
it('Check $scope assignments.', function() {
expect($scope.displayLoadContainer).toBe(true);
});
});
});
// Karma configuration
// http://karma-runner.github.io/0.12/config/configuration-file.html
// Generated on 2014-09-16 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'],
preprocessors: {
'app/scripts/controllers/dashboard.js': 'coverage'
},
// list of files/patterns to load in the browser
files: [
'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/tp-utils/app/scripts/services/tp-utils.js',
'bower_components/angular-local-storage/angular-local-storage.js',
'bower_components/ngInfiniteScroll/build/ng-infinite-scroll.js',
'bower_components/tp-services/dist/tp-services.js',
'app/scripts/app.js',
'app/scripts/api-dev.js',
'app/scripts/controllers/dashboard.js',
'test/spec/**/*.js'
],
// 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-coverage'
],
reporters: ['coverage'],
coverageReporter: {
type : 'text',
dir : 'coverage/'
},
// 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_'
});
};
Из любопытства: в каких браузерах вы задали Карму для тестирования? – Josep
Думаю, нам нужно увидеть ваш соответствующий файл 'karma.conf.js'. – Josh
Просто фантом. Я смог войти и добавить «прогресс» к журналистам ... Я использовал только «охват». Когда я сделал это, Карма начала давать мне более подробный/полезный результат. Я до сих пор не понимаю, почему хрюканье жасмина прошло, когда Карма взорвалась. – Swordfish0321