Skip to content

Commit

Permalink
[Tests] Load all sources (#1098)
Browse files Browse the repository at this point in the history
Load all source files when running Karma's test suite; this
ensures that code coverage metrics are not invalidated by
missing files. Fixes #1090.
  • Loading branch information
VWoeltjen authored and larkin committed Jul 28, 2016
1 parent 4d2f159 commit 59436f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
/*global require,window*/
var allTestFiles = [];
var TEST_REGEXP = /(Spec)\.js$/;
var SRC_REGEXP = /^\/base\/(src|platform).*\.js$/;

var pathToModule = function(path) {
return path.replace(/^\/base\//, '').replace(/\.js$/, '');
};

Object.keys(window.__karma__.files).forEach(function(file) {
if (TEST_REGEXP.test(file)) {
if (TEST_REGEXP.test(file) || SRC_REGEXP.test(file)) {
// Normalize paths to RequireJS module names.
allTestFiles.push(pathToModule(file));
}
Expand All @@ -38,6 +39,11 @@ Object.keys(window.__karma__.files).forEach(function(file) {
// Force es6-promise to load.
allTestFiles.unshift('es6-promise');

// Drop legacyRegistry, since it is at a different path by RequireJS config
allTestFiles = allTestFiles.filter(function (file) {
return file.indexOf('legacyRegistry') === -1;
});

requirejs.config({
// Karma serves files from the basePath defined in karma.conf.js
baseUrl: '/base',
Expand Down

0 comments on commit 59436f7

Please sign in to comment.