๐Ÿ“ฆ J-Sek / example-gulp-karma-include-all

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

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/J-Sek/example-gulp-karma-include-all.git
HTTPS git clone https://github.com/J-Sek/example-gulp-karma-include-all.git
SSH git clone git@github.com:J-Sek/example-gulp-karma-include-all.git
CLI gh repo clone J-Sek/example-gulp-karma-include-all
Czarniecki Czarniecki Add gulp task with includeAllSources: false 16331ff 9 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ screenshots
๐Ÿ“ Scripts
๐Ÿ“„ .gitignore
๐Ÿ“„ gulpfile.coffee
๐Ÿ“„ karma.conf.js
๐Ÿ“„ LICENSE
๐Ÿ“„ package.json
๐Ÿ“„ Readme.md
๐Ÿ“„ README.md

"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,
    ...
}