다음은 모듈 및 단위 테스트 설정입니다. $ state
을 설정하려고 시도하면 $injector.get("$state")
은 항상 재미 알 수없는 공급자를 던졌습니다. $ stateProvider < - $ state 오류 및 그 이유를 알 수 없습니다.
angular.module("my-module", [
//Third Party
"ui.bootstrap",
"ui.router",
"toaster",
"angular-loading-bar",
"ngAnimate",
"ngSanitize",
"ApplicationInsightsModule",
"pascalprecht.translate"
]);
describe("something descriptive and helpful",(): void => {
// a bunch of other service variables....
var $state: any;
// I've tried with and without this line
beforeEach(() => angular.module("ui.router"));
beforeEach(() => {
angular.module("my-module");
inject(($injector: ng.auto.IInjectorService): void => {
// a bunch of other service variable assignments
$state = $injector.get("$state");
});
});
스펙에서 실제 라우터를 사용하는 것은 어색함을 알아야합니다. 가능하면 $ stateProvider/$ state mocks를 사용하십시오. – estus
@estus 그래서 전체 경로 구성을 조롱해야한다면 ... 테스트의 요점은 무엇입니까? 그 시점에서 코드를 실제로 다시 작성하고 있습니다. 맞습니까? 그만한 가치는없는 것 같습니다. – Yatrix