I'm a beginner with Karma, and I can't make a test work on my project. I tried with this : http://ift.tt/1ycVXDm The exemple works with the "html page testing", but I can't make it work with start karma.conf.js (I got : Executed 0 of 0 ERROR)
Here is my karma.conf.js file :
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['mocha', 'chai'],
files: [
'node_modules/angular/angular.js',
'node_modules/angular-mocks/angular-mocks.js',
'src/client/api/category/category.model.js'
],
exclude: [
],
preprocessors: {
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
Here is the file I want to test : (src/client/api/category/category.model.js)
angular.module("aq.kiosk.api.category.models")
.factory("CategoryModel", [
function () {
var CategoryModel = function (data) {
this.id = "";
this.name = "";
this.description = "";
this.mediaUrls = [];
this.kind = "";
this.childCount = "";
this.issueCount = "";
this.issues = [];
if (angular.isDefined(data)) {
this.parse(data);
}
};
CategoryModel.prototype.parse = function (data) {
if (data) {
var self = this;
angular.forEach(data, function (value, key) {
self[key] = value;
});
}
};
return CategoryModel;
}
]);
And here is my test file :
describe("categorymodel", function() {
var data = {
childCount: "0",
description: "",
id: "16",
issueCount: 0,
kind: "",
mediaUrls: [],
name: "Lorem Ipsum"
};
beforeEach(module('aq.kiosk.api.category.models'));
var category = new CategoryModel(data);
describe("constructor", function(){
it('assigns a name', function () {
expect(category).to.have.property('name', "");
});
});
});
The error I get is : Uncaught Error: [$injector:nomod] Module 'aq.kiosk.api.category.models' is not available!
I don't know what i'm doing wrong, thank you very much for your help.
Aucun commentaire:
Enregistrer un commentaire