5
我得到this error。這是沿着我注射器無法解決所需的依賴性的東西,但即使我有限的角度知識我很確定這個代碼不應該依賴於任何模塊。
此代碼在瀏覽器中工作得很好,但它似乎並不想在我的測試中工作。我一直在關注examples從文檔
我的角度版本是1.2.13
(編輯:現在使用1.12.15
)。
這裏是我的代碼:
var app = angular.module('app', [])
.controller('GreetingCtrl', function ($scope) {
$scope.title = "Hello World!";
$scope.message = "Test, test. One? Two?";
});
這裏是一個的失敗茉莉花測試。
describe('app controllers', function() {
beforeEach(module('app'));
describe('GreetingCtrl', function() {
it('should says hello world', inject(function ($controller) {
var $scope = {};
$controller('GreetingCtrl', $scope);
expect($scope.title).toBe("Hello World!");
}));
});
});
我不相信它甚至不能運行我的測試,因爲它甚至在運行之前就失敗了。我相信我已經正確地連接了正確的文件。這是我從茉莉花測試跑步者收到的錯誤。
Error: [$injector:unpr] http://errors.angularjs.org/1.2.13/$injector/unpr?p0=%24scopeProvider%20%3C-%20%24scope (line 4569) (1)
編輯:嘗試升級到1.12.15
,一切都沒有改變。