ile açısal kontrolör test ederken ben Jasmine ile Açısal Apps test bir acemi değilim ve bu sorunun nedenini çözemiyorum tanımlanacak... Jasmine
kontrolör tanımsız Beklenen
programsModule.controller('ticketCtrl', ['$scope', function ($scope) {
$scope.disableSendBtn = true;
});
Ve bu birim test
'use strict';
describe('app', function() {
// variables
var $rootScope, $scope, $controller;
beforeEach(module('supportModule'));
describe('ticketCtrl', function() {
beforeEach(inject(function (_$rootScope_, _$controller_) {
$rootScope = _$rootScope_;
$scope = $rootScope.$new();
$controller = _$controller_('ticketCtrl', {
'$scope': $scope
});
}));
it('Should disable send btn', function() {
expect($scope.disableSendBtn).toEqual(true);
});
});
});
Ve bu outp olduğunu Test
TypeError: Cannot read property 'disableSendBtn' of undefined
ait ut Ve sınamak eğer $scope
değişken
it('Should $scope be defined', function() {
expect($scope).toBeDefined();
});
tarafından tanımlanmış veya değilse bu hata çok olsun
Expected undefined to be defined.
Yani sorun ne?
burada burada beforeEach(module('app'));
yanlış modülü kullanılan ve sabit
düzenleme jsFiddle http://jsfiddle.net/LeoAref/bn1wxycs/
olduğunu doğru modülü beforeEach(module('supportModule'));
Ve ben başka hata var:
Error: [ng:areq] Argument 'ticketCtrl' is not a function, got undefined
http://errors.angularjs.org/1.4.1/ng/areq?p0=ticketCtrl&p1=not%20a%20function%2C%20got%20undefined
deneyin '$ kontrolör _ ('ticketCtrl', { $ kapsamı: $ kapsam });' Ben de aynı hatayı ... –
@WayneEllery kullanmadan bir yazım hatası var: $ rootScope = \ _ $ controller_; <- bunu \ _ $ rootScope_ – LeoAref
var ama, tek tırnak sayesinde –