Skip to content

Commit

Permalink
#35 Measure Code Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg-rade committed Dec 4, 2019
1 parent e7c518c commit e1fc08d
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 103 deletions.
3 changes: 2 additions & 1 deletion docs/DevelopmentGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#Quickstart
## Frontend

### Requirements
Kotlin/JS uses `Gradle` for the build, for the JS runtime `NodeJS`, and for the JS dependency management part `npm`.
You should have installed:
Expand Down Expand Up @@ -239,4 +240,4 @@ nyc npm test
https://github.com/istanbuljs/nyc
## Gradle Build Overview
![Preview](./build-overview.png)
![Preview](./dev-overview.png)
36 changes: 0 additions & 36 deletions docs/build-overview.adoc

This file was deleted.

3 changes: 3 additions & 0 deletions docs/dev-mindmap.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
+++ Karma
+++ Broswerify
+++ ~~Mocha~~
+++ ChromeHeadless
+++ jasmine
+++ qunit
+++ PhtantomJS
+++ coverage
++++ istanbul
Expand Down
65 changes: 65 additions & 0 deletions docs/dev-overview.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.Development Overview Diagram
[plantuml,file="dev-overview.png"]
--
@startuml
skinparam nodesep 20
skinparam ranksep 5

top to bottom direction

component gradle <<build.tool>> {
component kotlinFrontend <<gradle.plugin>> as KF
component kotlin2js <<transpiler>> as K2JS
component DCE
}


package root #gold {
rectangle "build.gradle\nsettings.gradle\ngradle.properties" as GCFG
rectangle karma.conf.js as KC
rectangle package.json as PJ
GCFG -[hidden]--> PJ
}
package root.build #gold {
}
package root.node_modules as NM #gold {
component karma
component webpack
}
component NodeJS
component Browser

gradle .> GCFG : configured\nthrough
gradle --> webpack

K2JS --> root.build : generates\n*.js\n*-tests.js
KF --> KC : initially generates
KC -> PJ : requires
PJ -> NM : adds to

:Developer,\nalmost\ngone\ncrazy;-): as DEV
($ gradlew -t run) as RUN
($ npm install <> --save-dev) as NI
($ npm test) as TEST

DEV --> RUN
DEV --> NI
RUN --> gradle


component npm
NI .> npm : uses
NI -> PJ : updates


DEV --> TEST
TEST .> npm : uses
TEST --> karma : runs
karma --> Browser : displays\ntest results\nvia port 9876

note left of PJ
package.json.lock
end note

@enduml
--
37 changes: 21 additions & 16 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,38 @@
// Doc: see http://karma-runner.github.io/4.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: ['./build/**/*.js'],
excludes: ['./**/*.css'],
preprocessors: {
// 'build/**/*_test.js': ['webpack']
'./build/js-tests/*-tests.js': ['coverage']
},
frameworks: ['jasmine'],
plugins: [
require('karma-chrome-launcher'),
require('karma-coverage-istanbul-reporter'),
require('istanbul-instrumenter-loader'),
require('karma-jasmine'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
// require('karma-phantomjs-launcher'),
require('karma-chrome-launcher'),
require('karma-webpack')
],
reporters: ['coverage-istanbul'],
coverageIstanbulReporter: {
reports: ['html', 'lcovonly', 'text-summary'],
// if using webpack and pre-loaders, work around webpack breaking the source path
fixWebpackSourcePaths: true
},
reporters: ['progress', 'coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autowatch: true,
browsers: ['ChromeHeadless'],

// logLevel: config.LOG_DEBUG,
autoWatch: true,
singleRun: true,
concurrency: Infinity,
color: false
coverageReporter: {
includeAllSources: true,
dir: 'coverage/',
reporters: [
{type: "html", subdir: "html"},
// {type: "lcov"},
{type: 'text-summary'}
]

}
}
)
};
91 changes: 91 additions & 0 deletions karma.conf.js.new
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//https://github.com/mkraynov/kfsad/blob/master/karma.conf.js
// Karma configuration
// Generated on Thu Apr 04 2019 18:13:06 GMT+0300 (MSK)

module.exports = function(config) {
config.set({
plugins: [
require('karma-jasmine'),
require('karma-coverage'),
require('karma-chrome-launcher'),
require('karma-webpack'),
require('karma-mocha'),
require('karma-sourcemap-loader'),
// require('viewport'),
require('karma-viewport'),
],

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'viewport'],

// list of files / patterns to exclude
exclude: ['./**/*.css'],

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_WARN,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
// https://github.com/karma-runner/karma-chrome-launcher/issues/158#issuecomment-339265457
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,

client: {
mocha: {
timeout: 6000
}
},

// webpack specific things //
// list of files / patterns to load in the browser
files: [
{pattern: './build/js-tests/*-tests.js', watched: false}
],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'./build/js-tests/*-tests.js': ['webpack', 'sourcemap']
},

webpack: {},

webpackMiddleware: {
// webpack-dev-middleware configuration
// i. e.
stats: 'errors-only',
},
})
}
107 changes: 57 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@
{
"name": "kroviz",
"version": "0.3.0",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/joerg-rade/kroviz"
},
"homepage": "https://github.com/joerg-rade/kroviz",
"bugs": {
"url": "https://github.com/joerg-rade/kroviz/issues"
},
"devDependencies": {
"browserify": "^16.5.0",
"coverage": "^0.4.1",
"grunt": "^1.0.4",
"grunt-contrib-copy": "~1.0.0",
"grunt-po2json-remi": "~0.2.0",
"grunt-pot": "~0.3.0",
"istanbul": "^0.4.5",
"karma": "^4.3.0",
"karma-browserify": "^6.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^2.0.1",
"karma-jasmine": "^2.0.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-requirejs": "^1.1.0",
"karma-viewport": "^1.0.4",
"karma-webpack": "^4.0.2",
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"source-map-loader": "^0.2.4",
"sourcemap": "^0.1.0",
"viewport": "^2.0.1",
"webpack": "^4.41.0"
},
"dependencies": {
"default-passive-events": "^1.0.10",
"grunt-cli": "^1.3.2",
"istanbul-instrumenter-loader": "^3.0.1",
"karma-coverage-istanbul-reporter": "^2.1.0",
"karma-jasmine-html-reporter": "^1.4.2",
"kotlinx-serialization-runtime-js": "^0.5.0",
"progress": "^2.0.3",
"requirejs": "^2.3.6",
"watchify": "^3.11.1"
},
"scripts": {
"test": "./node_modules/.bin/karma start --single-run --browsers ChromeHeadless"
}
"name": "kroviz",
"version": "0.3.0",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/joerg-rade/kroviz.git"
},
"homepage": "https://github.com/joerg-rade/kroviz",
"bugs": {
"url": "https://github.com/joerg-rade/kroviz/issues"
},
"devDependencies": {
"browserify": "^16.5.0",
"coverage": "^0.4.1",
"grunt": "^1.0.4",
"grunt-contrib-copy": "~1.0.0",
"grunt-po2json-remi": "~0.2.0",
"grunt-pot": "~0.3.0",
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.1",
"jasmine-core": "^3.5.0",
"karma": "^4.3.0",
"karma-browserify": "^6.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-commonjs": "^1.0.0",
"karma-coverage": "^2.0.1",
"karma-jasmine": "^2.0.1",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-source-map-support": "^1.4.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-viewport": "^1.0.4",
"karma-webpack": "^4.0.2",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"source-map-loader": "^0.2.4",
"sourcemap": "^0.1.0",
"viewport": "^2.0.1",
"webpack": "^4.41.0",
"webpack-cli": "^3.3.10"
},
"dependencies": {
"default-passive-events": "^1.0.10",
"grunt-cli": "^1.3.2",
"kotlinx-serialization-runtime-js": "^0.5.0",
"progress": "^2.0.3",
"requirejs": "^2.3.6",
"watchify": "^3.11.1"
},
"scripts": {
"test": "karma start --browsers ChromeHeadless"
},
"directories": {
"doc": "docs"
},
"keywords": [],
"author": ""
}

0 comments on commit e1fc08d

Please sign in to comment.