13
Aşağıdaki birim testinin yürütülmesi "Hata: [$ enjektör: unpr] Bilinmeyen sağlayıcı: $ stateProvider < - $ state". Angular-ui-router.min.js dosyasını karma dosyasına ekledim.
describe("Unit tests", function() {
var $rootScope, $injector, $state;
console.log("hello");
beforeEach(inject(function(_$rootScope_, _$state_, _$injector_, $templateCache) {
console.log("hello1");
$rootScope = _$rootScope_;
$injector = _$injector_;
$state = _$state_;
}));
describe("states", function() {
it("verify state configuration", function() {
var config = $state.get("DRaaS");
console.log(config, "cc");
});
});
});
Bu cevap beni doğru yöne koydu. Karma.conf içindeki dosyamıma 'açısal-ui-yönlendirici 'eklemeyi unuttum. – Raulucco
Şu anda bunun aslında gerekli olduğu gerçeğinden dolayı kesinlikle karma nefret ediyorum! $ StateProvider sahte/saplama/sahte yapmak için herhangi bir yolu var, bu yüzden 'ui yönlendirici' gerek yok? Kodumu tecritte test edebilmeyi (böylece UNIT testleri) yapabilmek ve tüm bu bağımlılıkları ortaya çıkarmak istiyorum. –
@AaronJanes evet var. Bu gibi bir şeyi kullanabilirsiniz: $ offer.service ('$ state', işlev ($ q) { var $ stateService = { akım: { url: "/", görüntüleme: {}, name: "root " " }; return $ stateService; }); – BobDoleForPresident