I've a small problem with my coverage report. I've got functions tested with jasmine but the coverage report tells me that these functions are not covered.
I'm using jasminejs with requirejs to test my code which uses requirejs (with backbone) too. To run the specs gunt with grunt-contrib-jasmine, grunt-template-jasmine-istanbul and grunt-template-jasmine-requirejs is used. The tests run completely fine and if i put a log into the uncovered function, i can see that these function is called multiple times.
Do i have a wrong setup or why is increaseOffset not covered?
Here is my grunt configuration
jasmine: {
coverage: {
src: [
'js/collection/*.js',
'js/model/*.js',
'js/util/*.js',
'js/view/**/*.js'
],
options: {
specs: ['spec/**/*Test.js'],
summary: true,
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: 'test/coverage.json',
report: {
type: 'html',
options: {
dir: 'test/coverage'
}
},
thresholds: {
lines: 50,
statements: 75,
branches: 75,
functions: 90
},
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfigFile: 'js/configuration.js',
requireConfig: {
waitSeconds: 10
}
}
},
junit: {
path: 'test/junit'
}
}
}
}
Here a sample class
define([
'jquery',
'underscore',
'backbone'
], function Filter_load($, _, Backone) {
'use strict';
/**
* Representation of Filter settings
*/
var Filter = Backone.Model.extend({
/**
* Define default values
*/
defaults: {
tags: [],
range: 0,
offset: 0,
limit: 10
},
/**
* Increase filter offset by filter limit
*/
increaseOffset: function Filter_increaseOffset() {
this.attributes.offset += this.attributes.limit;
}
});
return Filter;
});
And here a part of the test for this class
define([
'model/Filter'
], function FilterTest_load(Filter) {
/**
* Validate the model/Filter class
*/
return describe('A Filter', function() {
/**
* Validate behavior of offset property
*/
describe('offset', function() {
var filter = new Filter();
it('should be 0', function() {
expect(filter.get('offset')).toBe(0);
});
it('and change to 100', function() {
filter.set('offset', 100);
expect(filter.get('offset')).toBe(100);
});
it('should increase by 11', function() {
filter.set('limit', 11);
filter.set('offset', 0);
expect(filter.get('offset')).toBe(0);
filter.increaseOffset();
expect(filter.get('offset')).toBe(11);
});
it('should increase stay on 10', function() {
filter.set('limit', 0);
filter.set('offset', 10);
expect(filter.get('offset')).toBe(10);
filter.increaseOffset();
expect(filter.get('offset')).toBe(10);
});
});
});
});
Thank in advance