Skip to content

Example project that include all sources while calculating coverage with gulp and karma

License

Notifications You must be signed in to change notification settings

J-Sek/example-gulp-karma-include-all

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

"Include All" with gulp and karma-coverage

Example project using Require.js and file path patterns. Prooving it is possible to get 0% coverage and not worry about confliciting implementations.

Note: you don't need to use Require.js across the solution.



Setup:

npm install

Run:

npm test

or:

gulp coverage

compare with:

gulp coverage_tested

How is it working?

  • Set pattern to match all files but include none:
{pattern: 'Scripts/App/**/*.js', included: false},
{pattern: 'Scripts/Test/**/*Spec.js', included: false},
  • Configure require.js
var tests = [];
for (var file in window.__karma__.files) {
    if (/Spec\.js$/.test(file)) {
        tests.push(file);
    }
}

require(['/base/Scripts/App/Calc.js']);

requirejs.config({
    deps: tests,
    callback: window.__karma__.start
});
  • Use additional flag for Istanbul
coverageReporter: {
    includeAllSources: true,
    ...
}

About

Example project that include all sources while calculating coverage with gulp and karma

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published