print text summary of js test coverage

This commit is contained in:
Christoph Wurst 2016-09-19 15:05:35 +02:00
Родитель c38be33fc8
Коммит 9e9ed7801a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CC42AC2A7F0E56D8
4 изменённых файлов: 52 добавлений и 19 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -21,3 +21,6 @@ build/artifacts
nbproject/
translations.js
# JS coverage
coverage/

Просмотреть файл

@ -1,4 +1,5 @@
var allTestFiles = [];
var allModules = [];
var TEST_REGEXP = /(spec|test)\.js$/i;
// Get a list of all the test files to include
@ -8,10 +9,46 @@ Object.keys(window.__karma__.files).forEach(function(file) {
// If you require sub-dependencies of test files to be loaded as-is (requiring file extension)
// then do not normalize the paths
var normalizedTestModule = file.replace(/^\/base\/js\/|\.js$/g, '');
allTestFiles.push(normalizedTestModule);
if (normalizedTestModule.substring(0, 'tests'.length) === 'tests') {
allTestFiles.push(normalizedTestModule);
}
} else {
var excluded = ['OC', 'autoredirect', 'searchproxy', 'app'];
var normalizedModule = file.replace(/^\/base\/js\/|\.js$/g, '');
if (normalizedModule.substring(0, '/base/js/'.length) === '/base/js/') {
normalizedModule = normalizedModule.substring('/base/js/'.length);
}
if (normalizedModule.substring(0, 'vendor'.length) === 'vendor') {
return;
}
if (normalizedModule.substring(0, 'templates'.length) === 'templates') {
return;
}
if (normalizedModule.substring(0, '/base/node_modules'.length) === '/base/node_modules') {
return;
}
if (excluded.indexOf(normalizedModule) !== -1) {
return;
}
allModules.push(normalizedModule);
}
});
OC = {
Notification: {
showTemporary: function() {
}
},
generateUrl: function(url) {
return url;
},
linkToRemote: function() {
}
};
require.config({
// Karma serves files under /base, which is the basePath from your config file
baseUrl: '/base/js',
@ -39,16 +76,7 @@ require.config({
}
},
// dynamically load all test files
deps: allTestFiles,
deps: allTestFiles.concat(allModules),
// we have to kickoff jasmine, as it is asynchronous
callback: window.__karma__.start
});
// Define Mock for modules that do not exist while testing
define('OC', [], function() {
return {
generateUrl: function(url) {
return url;
}
}
});

Просмотреть файл

@ -10,15 +10,10 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
'js/vendor/jquery/dist/jquery.js',
{pattern: 'js/*/*.js', included: false},
{pattern: 'js/**/*.js', included: false},
{pattern: 'js/*.js', included: false},
{pattern: 'js/templates/*.html', included: false},
{pattern: 'js/vendor/backbone/backbone.js', included: false},
{pattern: 'js/vendor/backbone.marionette/lib/backbone.marionette.js', included: false},
{pattern: 'js/vendor/backbone.radio/build/backbone.radio.js', included: false},
{pattern: 'js/vendor/handlebars/handlebars.js', included: false},
{pattern: 'js/vendor/text/text.js', included: false},
{pattern: 'js/vendor/underscore/underscore.js', included: false},
{pattern: 'js/vendor/**/*.js', included: false},
{pattern: 'js/tests/*.js', included: false},
'js/tests/test-main.js'
],
@ -31,11 +26,16 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'js/**[!vendor]/*[!spec].js': ['coverage']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
reporters: ['progress', 'coverage'],
coverageReporter: {
type: 'text-summary',
dir: 'coverage/'
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)

Просмотреть файл

@ -29,11 +29,13 @@
"grunt-contrib-jshint": "^0.11.3",
"grunt-jscs": "^1.8.0",
"grunt-karma": "^0.12.1",
"istanbul": "^0.4.5",
"jasmine-core": "^2.5.2",
"jscs-jsdoc": "^1.0.1",
"jshint": "^2.7.0",
"jsxhint": "^0.14.0",
"karma": "^1.3.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-requirejs": "^1.1.0",