vendredi 20 mars 2015

angular.mock.inject causing $injector:moduleerr

I am setting up unit tests using Karma, Require.js, Mocha and Chai. After setting everything up, I have a simple spec file to test a controller and a scope variable.


I know an inject function needs to be used to get $controller service that will instantiate the controller. I am unable to do this. Here is what I have :



define([

'angular',
'angularMocks'

], function() {

describe('MyCtrl', function() {

var $controller;

beforeEach(angular.mock.module('MyApp'));

// ////////// ATTEMPT 1

// beforeEach(angular.mock.inject(function(_$controller_){

// $controller = _$controller_;
// }));

// ////////// ATTEMPT 2

// it('should', inject(function(_$rootScope_, _$controller_, _$httpBackend_) {

// }));

it('should', function() {

// ////////// GOAL

expect($scope.message).to.equal('hello world');
});
});
});

Aucun commentaire:

Enregistrer un commentaire