Say I have the following code:
define([
'a'
], function(a) {
return {
initialize: function() {
},
stuff: function() {
}
};
});
Istanbul reports that only 1/3 functions have been tested. Which is somewhat true as I have only run a test against main.initialize
.
How can I get Istanbul to ignore the function used for define callback?
Edit: Additional Gruntfile.js
config
jasmine: {
coverage: {
src: 'src/assets/js/app/**/*.js',
options: {
specs: 'src/assets/js/spec/**/*Spec.js',
host: 'http://127.0.0.1:8000/',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
//files: 'src/assets/js/app/**/*.js',
coverage: 'bin/coverage/coverage.json',
report: [
{type: 'html', options: {dir: 'src/coverage/html'}},
{type: 'text-summary'}
],
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
baseUrl: 'src/assets/js',
paths: {
/* 'jquery': 'lib/jquery',
'underscore': 'lib/lodash',
'text': 'lib/text',
'i18n': 'lib/i18n',*/
}
}
}
},
keepRunner: true
}
}
}
Edit: Example Spec
define([
'app/main'
], function(main) {
describe('app/main', function() {
it('initailize should not error', function() {
expect(main.initialize()).toBe(undefined);
});
});
});
Istanbul let's you define your own custom ignores explicitly in your code here
You may use /* istanbul ignore define */
at the top of your file to prevent define(...)
from been checked.
Hope it'll help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With