var testModules = []; var TEST_REGEXP = /^\/base\/test\/spec\/\S*.js$/i; var pathToModule = function(path) { return path.replace(/^\/base\//, '').replace(/\.js$/, ''); }; testModules.push('es5-ff-spa-loader'); Object.keys(window.__karma__.files).forEach(function(file) { //console.log('file: '+file); if (TEST_REGEXP.test(file)) { var fileNew = pathToModule(file); testModules.push(fileNew); //console.log('file: '+file+' fileNew: '+fileNew); } }); require.config({ baseUrl : '/base/', enforceDefine : true, xhtml : false, waitSeconds : 30, deps : testModules, callback : window.__karma__.start });