Test passes in browser, but fails in Test Explorer using Chutzpah.
I am using jasmine angular and angular-ui with the Chutzpah Test Adaptor For Test Explorer in Visual Studio.
The paths are correct only difference is I was using a cdn for angular.min and angular-ui in the browser test.
I read several places to use alter the Chutzpah Settings by adding a chutpah.json and something with adding/removing tests from code coverage
see This posted answer to similar question
JS Module
(function () {
var module;
module = angular.module('emed', ['ui.bootstrap']);
}());
Controller
(function (module) {
module.controller('AuthenticationCtrl', ['$scope', '$modal', '$log', '$modalInstance', 'AuthService', 'url', AuthModalCtrl]);
function AuthModalCtrl($scope, $modal, $log, $modalInstance, AuthService, url) {
var service = AuthService;
url = url;
var previousUserName;
AuthService.getModel(url.Get).then(
function (model) {
$scope.model = model;
previousUserName = model.Username;
});
///.....
///more code here
}
}(angular.module('emed')));
Test:
/// <chutzpah_reference path="../../../Scripts/sinon-1.9.1.js">
/// <chutzpah_reference path="../../../Scripts/angular.min.js" />
/// <chutzpah_reference path="../../../Scripts/angular-ui.js" />
/// <chutzpah_reference path="../../../Scripts/angular-mocks.js" />
/// <chutzpah_reference path="../../../../Dashboard/Areas/Emed/Scripts/ng/Modules/emed.js">
/// <chutzpah_reference path="../../../../Dashboard/Areas/Emed/Scripts/ng/Service/AuthenticateService.js">
/// <chutzpah_reference path="../../../../Dashboard/Areas/Emed/Scripts/ng/Controllers/Modals/AuthenticationCtrl.js">
(function () {
describe("During construction of the controller", function () {
var scope, controller, authServiceStub, modalInstance, url, deferred ,stub;
beforeEach(function () {
module("emed");
inject(function ($rootScope, $controller, AuthService, $q) {
scope = $rootScope.$new();
deferred = $q.defer();
//authServiceStub = sinon.stub(AuthService, "getModel", function () {
// console.log("in stub");
// deferred.resolve('Remote call result');
// return deferred.promise;
//});
authServiceStub = sinon.stub(AuthService);
authServiceStub.getModel.returns(deferred.promise);
modalInstance = { close: function () { }, dismiss: function () { } };
url = "localhost/Modal/AuthenticateModel?pid=2&ptid=1";
controller = $controller('AuthenticationCtrl', { $scope: scope, $modalInstance: modalInstance, url: url });
});
});
it('should call the modal controller to get its model', function () {
console.log("in test");
//sinon.assert(authServiceStub.called);
expect(authServiceStub.getModel.called).toBe(true);
});
});
}());
And i get the following error:
Error: [$injector:modulerr] Failed to instantiate module emed due to: [$injector:nomod] Module 'emed' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://ift.tt/1IBXZiG$injector/nomod?p0=emed
Any Ideas on how to fix this??
Aucun commentaire:
Enregistrer un commentaire