jeudi 19 février 2015

Gulp test can not find module


I generated my web application with [gulp angular][1]. Then I created a service and want to test it.


Module file is app.module.js



angular.module('text', []);


Service file is text.service.js



(function () {
'use strict';
angular.module('text')
.factory('description',TextService);

TextService.$inject = ['$http']

function TextService($http) {

return {
QueryStaticText: queryStaticText

};

function queryStaticText(link) {
return link;
}
}

})();


Test file is text.service.spec.js



'use strict';

describe('TextService', function () {
var description;

beforeEach(function () {

module('text');

inject(function (_description_) {
description = _description_;
});

});

it('should return text', function () {
expect(description.QueryStaticText("Hello")).toEqual("Hello anu");
});
});


In the console I execute gulp test and I've got the error message



[22:02:44] Using gulpfile /Volumes/Developer/angularjs/project/gulpfile.js
[22:02:44] Starting 'test'...
[22:02:45] Starting Karma server...
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Mac OS X)]: Connected on socket 1KW_uYCk45moVKwfgAd2 with id 19804685
PhantomJS 1.9.8 (Mac OS X) ERROR
Error: [$injector:nomod] Module 'text' 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/1ES7hnZ
at /Volumes/Developer/angularjs/project/bower_components/angular/angular.js:1769



/Volumes/Developer/angularjs/project/gulp/unit-tests.js:30
throw err;

[1]: http://ift.tt/1keGyao


The text module is not loaded, how can I load it?





Aucun commentaire:

Enregistrer un commentaire